users@glassfish.java.net

Re: Enumeration mapping JPA

From: <glassfish_at_javadesktop.org>
Date: Thu, 18 Oct 2007 02:29:57 PDT

Thanks for the advice. It was really helpful.

Since it was Strings in the enum in the database I had to change the enum in Java to have String arguments. There is however a problem with this solution. If I create queries in my session beans which selects entities which has this construction I still have to use the persistent field in my where statement to filter the entities but I guess I have to live with that.

I could also use some design advice:
Do you usually put EJB QL queries in you entity or session beans? I currently have all queries in my session beans. If I for example want to filter a set of entities in a one-to -many relationship, would you add a getter method to the entity bean which retrieves them with a EJB QL query?

Also, do you have a solution how to create a query where you want to filter the result in where statement for all entities that exist in a set. Example "select objects from table where objects.value in ('x','y','z')". I have only managed to create a query like this by just building a String. I cannot seem to use query.setParameter and replace the values in the in statement with a ":set".
[Message sent by forum member 'woel' (woel)]

http://forums.java.net/jive/thread.jspa?messageID=240873