Theodore David Williams

Ranch Hand
+ Follow
since Dec 21, 2009
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Theodore David Williams

I cannot seem to find a standard way to get a QName as a string with the prefix as output after mashaling to XML.

I.E. when I marshal to XML I get

Is there a standard way to turn a QName into this string?

Of course I could do:

QName qName = .....
String withPrefix = qName.getPrefix() + ":" + qName.getLocalName();

But that seems messy.
I have a use case in which I would like to run one 'application/service' at a time.

In a simple example lets say I have a bunch of Services. Each one can be added to a queue. Queue will run one service until completion and then run the next. If the queue is empty it just hangs around until something is put on. Basically I would like to enforce single 'threading', ie I do not want two of these services running at the same time.

To make things a little more complicated I would like to run this in an app server (i.e. JBoss AS).

I know in Java I could probably do something like use a blockingqueue and pull one service off at a time. But I don't think it is a good idea to implement your own threading solution in an app server.

Any ideas?

11 years ago
Probably heard this before, but I would like to get away from using JAI for my image processing needs. I have searched all around for a suitable alternative but have not had any luck. Anyone out there using a good java library (that is not dead or dying) for image manipulation. Stuff I currently do it scale , translate, mosaic.

Is java giving up on image processing all together, I cannot seem to find anything in the works.
11 years ago
Please database agnostic. Ie I want one and only one (if possible) query that will work on oracle, MySQL and Postgres.

According to the docs CAST is a standard and implemented on all DBs just can't get this one query to work on MySQL.
I would like to form a select statement to cast a number column to a varchar so I can append some additional info in the response.

Select 'test-' || CAST(id as varchar(10)) as testcolumn from some_table;

However I cannot get this to work in MySQL and oracle. I would like this statement to stay database agnostic. Any ideas?

Here was the subtle problem:

Call to single result seemed to indicate to hibernate to not bring back all the joins into memory.

Even though only one dir comes back (the distinct keyword in hibernate indicates to populate all children but only give back the root dir) a call to get result list works wonders.

All entities that were lazy loaded were brought back into memory in one select statement.

Went from ~30 seconds populating my tree server side to ~1 second.
I am using hibernate and as stated before hibernate does support this type of query. Any hibernate users out there have any success with this? I don't think this is a 'hard' java problem I just must be missing something.
I am not at all sure if that is something hibernate does under the covers. But I do know that hibernate does indeed support a recursive fetch. From hibernate docs;

A fetch join does not usually need to assign an alias, because the associated objects should not be used in the where clause (or any other clause). The associated objects are also not returned directly in the query results. Instead, they may be accessed via the parent object. The only reason you might need an alias is if you are recursively join fetching a further collection:

from Cat as cat
inner join fetch cat.mate
left join fetch cat.kittens child
left join fetch child.kittens

I am not sure why it is only grabbing some of the children.
Messed around with inner vs outer joins with no luck. I also noticed that it seems like the recursion goes 1 level deep and then stops. Is there a property somewhere that defines how deep to go in recursive join like this?
I have a directory type structure represented as entities, i.e. think Directory entity and File entity.

The Directory entity has a collection of File entities and a collection of Directory entities.

I want to get the root directory and 'pre load' all directories and there files.

I am trying:

The query works it just does not pre load everything. I get all of the root directories and the root files, but when I start going into the sub directories and get the files queries are made. I.E. it seems like the recursion is not working.

I have also tried just a JOIN FETCH (which I think does an inner join fetch) with no luck.

Any ideas?
Yeah that works thanks. I still have a problem in that I want to split on multiple words and characters. And I also want to ignore case
I.E. can I split on the words and characters below?
'the', 'The'
'to', 'To', 'TO'
12 years ago
Is there a way to split a string on a word.

12 years ago
I have a class that will have a couple of 'parsers'. These parsers are responsible for parsing a string into a certain class

Ok so assume a vin number has letters in it so it has to be a string not an integer/number.

I want to be able to create my garage with a cars vin, or my cars make/model. Once I have created the garage, I want to be able get my cars make/model or vin. So I want to be able to construct the garage with a vin or a make model, but obviously I cannot have two constructors with the same String argument.

Basically I want be able to go from
car -> makeModel
makeModel -> car

car -> vin
vin -> car

Which is why I have those parsers, but how do I get a car object inside my garage and still be able to go back and forth?
I did think about a generic context but I was trying to avoid the user of the api to avoid having to know what type 'Stuff' was. But after you response and a few days of thinking I so do not think that there is any way around it.

Thanks so much for the response. And for moving post!!!
I am messing around with design patterns (I am still new) and I was trying to write some code to take advantage of generics.

I.E. I was wondering how someone might implement the strategy pattern if the return type on the interfaces method could be different. Some code would probably help explain.

Seems simple enough so far. But here is where I get stuck. How can I inject a concrete 'stuff' implementation into another class at runtime to get a certain behavior but still take advantage of type safety.

I have been thinking about this for a few days and I am really stumped. Can you use generics to inject a certain behavior at runtime.