One-to-many with subclasses

Hello again,
there seems to be a problem with one-to-many relations involving
inheritence...
Let me describe the setting:
class AbstractUsecase {
// element-type=Account
Set accounts;
class Usecase extends AbstractUsecase {
class Account extends AbstractAccount implements InstanceCallbacks {
// element-type=AccountRevisionItem
List revisions;
AbstractUsecase uc;
class AccountRevisionItem extends Account {
long time;
User user;
As you can see a simple model (in uml it looks much more better).
In the method jdoPreStore() of Account an object of type
AccountRevisionItem will added to revisions. This new object holds the
data of Account, the User and timestamp of the modifing. So we are able to
trace every change on the date (user, date). Metadata looks like this:
<class name="AbstractUsecase"/>
<class name="Usecase" persistence-capable-superclass="AbstractUsecase">
<class name="Abstractaccount"/>
<class name="Account" persistence-capable-superclass="AbstractAccount">
<extension vendor-name="kodo" key="table" value="Account"/>
<field name="revisions">
<collection element-type="AccountRevisionItem"/>
</field>
</class>
<class name="AccountRevisionItem"
persistence-capable-superclass="Account"/>
When i get a extent of all Accounts i can fetch all revisions of each
Account.
Now the problem: When i fetch all accounts of a usecase there are objects
included of type Account AND AccountRevisionItem. The generated SQL code
shows also why: ...t0.JDOCLASSX IN ('tolina.data.Account',
'tolina.data.AccountRevisionItem')...
Kodo tries when fetching a set of Accounts also all subclasses of
Accounts! How can i say: this set contains only accounts and no fetching
of subclasses is needed!
I would be grateful for any help!
PS: I noticed that kodo deletes all elements of a list when inserting a
new element, i remember there a several faqs around this. Can you anyway
give a work-a-round?

Hi Patrick,
i found my mistake: in the copy() method of AccountRevisionItem which
copies the attributes of the Accountobject, i copied the Usecase reference
too.
So when all Accounts of a usecase will be fetched the copied
AccountRevisionItem matched too, because of the fk of the usecase :[
I was wondering why i get the RevisionItem although i never added it to
the list of accounts in the usecase - now i know :)
Your strategy to fetch all objects of the desired class AND subclass when
traverse a relation is of course right. But can i control it like in the
case from extents?
Your proposal to use sets instead of lists is not really the solution,
because sets have no order of the containing elements!
I have to life with sets because deleting all elements when inserting a
new one is not really performant...
Thanks anyway for your quick help!
I promise this was not the last time, because we will use kodo in a
prototyp-project - when it will be a success we will buy kodo.
Patrick Linskey wrote:
How are you getting the extent? If you do:
Extent e = pm.getExtent (Account.class, true);
you will get all subclasses. If you do:
Extent e = pm.getExtent (Account.class, false);
then you will get an extent of just Account objects -- no subclasses.
Now, if you're traversing a relation, we will always return all objects
in that relation, regardless of subclass. So, if you have a one-many
relation from UseCase to Account, we'll return all objects in that
relation. However, that relation should only contain data that you put
into it, so if you never put anything but Account objects into it, then
you should not see anything else come out.
Regarding your collection question -- if you declare the field as a
java.util.Set, modifications of the collection will be much more efficient.
-Patrick
Claudius Gr__ver wrote:
Hello again,
there seems to be a problem with one-to-many relations involving
inheritence...
Let me describe the setting:
class AbstractUsecase {
// element-type=Account
Set accounts;
class Usecase extends AbstractUsecase {
class Account extends AbstractAccount implements InstanceCallbacks {
// element-type=AccountRevisionItem
List revisions;
AbstractUsecase uc;
class AccountRevisionItem extends Account {
long time;
User user;
As you can see a simple model (in uml it looks much more better).
In the method jdoPreStore() of Account an object of type
AccountRevisionItem will added to revisions. This new object holds the
data of Account, the User and timestamp of the modifing. So we are able to
trace every change on the date (user, date). Metadata looks like this:
When i get a extent of all Accounts i can fetch all revisions of each
Account.
Now the problem: When i fetch all accounts of a usecase there are objects
included of type Account AND AccountRevisionItem. The generated SQL code
shows also why: ...t0.JDOCLASSX IN ('tolina.data.Account',
'tolina.data.AccountRevisionItem')...
Kodo tries when fetching a set of Accounts also all subclasses of
Accounts! How can i say: this set contains only accounts and no fetching
of subclasses is needed!
I would be grateful for any help!
PS: I noticed that kodo deletes all elements of a list when inserting a
new element, i remember there a several faqs around this. Can you anyway
give a work-a-round?
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com

Similar Messages

  • OR mapping one-to-many with the movie EJB application

    Hi,
    I have downloaded from Orion the Movie EJB application with
    OR mapping one-to-many.
    When I ran it, it's fine. But I have spurious messages on
    my OC4J LOG:
    Oracle9iAS (9.0.2.0.0) Containers for J2EE initialized
    java.lang.Exception
    at MovieHome_EntityHomeWrapper53.getLazyInstance(MovieHome_EntityHomeWrapper53.java:219)
    at Movie_ORCollection29.getObjects(Movie_ORCollection29.java:43)
    at com.evermind.server.ejb.ORCollection.size(ORCollection.java:42)
    at java.util.ArrayList.<init>(ArrayList.java:125)
    at com.evermind.server.ejb.ORCollection.getReplacement(ORCollection.java:22)
    at Director_EntityBeanWrapper1.getMovies(Director_EntityBeanWrapper1.java:1318)
    at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at MovieHome_EntityHomeWrapper53.getLazyInstance(MovieHome_EntityHomeWrapper53.java:219)
    at Movie_ORCollection29.getObjects(Movie_ORCollection29.java:43)
    at com.evermind.server.ejb.ORCollection.size(ORCollection.java:42)
    at java.util.ArrayList.<init>(ArrayList.java:125)
    at com.evermind.server.ejb.ORCollection.getReplacement(ORCollection.java:22)
    at Director_EntityBeanWrapper1.getMovies(Director_EntityBeanWrapper1.java:1318)
    at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at DirectorHome_EntityHomeWrapper28.getLazyInstance(DirectorHome_EntityHomeWrapper28.java:207)
    at Movie_EntityBeanWrapper3.loadState(Movie_EntityBeanWrapper3.java:1575)
    at Movie_EntityBeanWrapper3.getTitle(Movie_EntityBeanWrapper3.java:1374) at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at DirectorHome_EntityHomeWrapper28.getLazyInstance(DirectorHome_EntityHomeWrapper28.java:207)
    at Movie_EntityBeanWrapper3.loadState(Movie_EntityBeanWrapper3.java:1575)
    at Movie_EntityBeanWrapper3.getTitle(Movie_EntityBeanWrapper3.java:1374) at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    Auto-unpacking /u00/app/oracle/product/9i/j2ee/home/applications/MovieDatabase.ear... done.
    Auto-unpacking /u00/app/oracle/product/9i/j2ee/home/applications/MovieDatabase/MovieDatabaseWebClient.war... done.
    Auto-deploying MovieDatabaseBeans.jar (Class 'moviebeans.Actor' had been updated)... done.
    java.lang.Exception
    at ActorHome_EntityHomeWrapper9.getLazyInstance(ActorHome_EntityHomeWrapper9.java:207)
    at MovieActorJuncture_ORCollection10.getObjects(MovieActorJuncture_ORCollection10.java:49)
    at com.evermind.server.ejb.ORCollection.size(ORCollection.java:42)
    at moviebeans.ActorBean.getMovies(Unknown Source)
    at Actor_EntityBeanWrapper4.getMovies(Actor_EntityBeanWrapper4.java:983) at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at MovieHome_EntityHomeWrapper57.getLazyInstance(MovieHome_EntityHomeWrapper57.java:219)
    at MovieActorJuncture_ORCollection10.getObjects(MovieActorJuncture_ORCollection10.java:69)
    at com.evermind.server.ejb.ORCollection.size(ORCollection.java:42)
    at moviebeans.ActorBean.getMovies(Unknown Source)
    at Actor_EntityBeanWrapper4.getMovies(Actor_EntityBeanWrapper4.java:983) at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at MovieActorJunctureHome_EntityHomeWrapper39.getLazyInstance(MovieActorJunctureHome_EntityHomeWrapper39.java:216)
    at MovieActorJuncture_ORCollection10.getObjects(MovieActorJuncture_ORCollection10.java:86)
    at com.evermind.server.ejb.ORCollection.size(ORCollection.java:42)
    at moviebeans.ActorBean.getMovies(Unknown Source)
    at Actor_EntityBeanWrapper4.getMovies(Actor_EntityBeanWrapper4.java:983) at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at DirectorHome_EntityHomeWrapper32.getLazyInstance(DirectorHome_EntityHomeWrapper32.java:207)
    at Movie_EntityBeanWrapper7.loadState(Movie_EntityBeanWrapper7.java:1575)
    at MovieHome_EntityHomeWrapper57.findExistingEntity(MovieHome_EntityHomeWrapper57.java:108)
    at MovieHome_EntityHomeWrapper57.activateEntity(MovieHome_EntityHomeWrapper57.java:157)
    at MovieHome_EntityHomeWrapper57.findByPrimaryKey(MovieHome_EntityHomeWrapper57.java:359)
    at MovieHome_EntityHomeWrapper57.getEJBObject(MovieHome_EntityHomeWrapper57.java:213)
    at com.evermind.server.ejb.EntityHandle.getEJBObject(EntityHandle.java:53)
    at com.evermind.server.ejb.EJBInputStream.resolveObject(EJBInputStream.java:41)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:405)
    at java.io.ObjectInputStream.inputArray(ObjectInputStream.java:1148)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:380)
    at java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2268)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:525)
    at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1417)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:392)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:242)
    at com.evermind.server.ejb.EJBUtils.cloneObject(EJBUtils.java:346)
    at Actor_EntityBeanWrapper4.getMovies(Actor_EntityBeanWrapper4.java:1075)
    at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at DirectorHome_EntityHomeWrapper32.getLazyInstance(DirectorHome_EntityHomeWrapper32.java:207)
    at Movie_EntityBeanWrapper7.loadState(Movie_EntityBeanWrapper7.java:1575)
    at Movie_EntityBeanWrapper7.getTitle(Movie_EntityBeanWrapper7.java:1374) at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    Auto-unpacking /u00/app/oracle/product/9i/j2ee/home/applications/MovieDatabase.ear... done.
    java.lang.Exception
    at ActorHome_EntityHomeWrapper9.getLazyInstance(ActorHome_EntityHomeWrapper9.java:207)
    at MovieActorJuncture_ORCollection10.getObjects(MovieActorJuncture_ORCollection10.java:49)
    at com.evermind.server.ejb.ORCollection.size(ORCollection.java:42)
    at moviebeans.ActorBean.getMovies(Unknown Source)
    at Actor_EntityBeanWrapper4.getMovies(Actor_EntityBeanWrapper4.java:983) at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at MovieHome_EntityHomeWrapper57.getLazyInstance(MovieHome_EntityHomeWrapper57.java:219)
    at MovieActorJuncture_ORCollection10.getObjects(MovieActorJuncture_ORCollection10.java:69)
    at com.evermind.server.ejb.ORCollection.size(ORCollection.java:42)
    at moviebeans.ActorBean.getMovies(Unknown Source)
    at Actor_EntityBeanWrapper4.getMovies(Actor_EntityBeanWrapper4.java:983) at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at MovieActorJunctureHome_EntityHomeWrapper39.getLazyInstance(MovieActorJunctureHome_EntityHomeWrapper39.java:216)
    at MovieActorJuncture_ORCollection10.getObjects(MovieActorJuncture_ORCollection10.java:86)
    at com.evermind.server.ejb.ORCollection.size(ORCollection.java:42)
    at moviebeans.ActorBean.getMovies(Unknown Source)
    at Actor_EntityBeanWrapper4.getMovies(Actor_EntityBeanWrapper4.java:983) at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at DirectorHome_EntityHomeWrapper32.getLazyInstance(DirectorHome_EntityHomeWrapper32.java:207)
    at Movie_EntityBeanWrapper7.loadState(Movie_EntityBeanWrapper7.java:1575)
    at MovieHome_EntityHomeWrapper57.findExistingEntity(MovieHome_EntityHomeWrapper57.java:108)
    at MovieHome_EntityHomeWrapper57.activateEntity(MovieHome_EntityHomeWrapper57.java:157)
    at MovieHome_EntityHomeWrapper57.findByPrimaryKey(MovieHome_EntityHomeWrapper57.java:359)
    at MovieHome_EntityHomeWrapper57.getEJBObject(MovieHome_EntityHomeWrapper57.java:213)
    at com.evermind.server.ejb.EntityHandle.getEJBObject(EntityHandle.java:53)
    at com.evermind.server.ejb.EJBInputStream.resolveObject(EJBInputStream.java:41)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:405)
    at java.io.ObjectInputStream.inputArray(ObjectInputStream.java:1148)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:380)
    at java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2268)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:525)
    at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1417)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:392)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:242)
    at com.evermind.server.ejb.EJBUtils.cloneObject(EJBUtils.java:346)
    at Actor_EntityBeanWrapper4.getMovies(Actor_EntityBeanWrapper4.java:1075)
    at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    java.lang.Exception
    at DirectorHome_EntityHomeWrapper32.getLazyInstance(DirectorHome_EntityHomeWrapper32.java:207)
    at Movie_EntityBeanWrapper7.loadState(Movie_EntityBeanWrapper7.java:1575)
    at Movie_EntityBeanWrapper7.getTitle(Movie_EntityBeanWrapper7.java:1374) at webclient.MovieDatabaseServlet.processQueryRequest(Unknown Source)
    at webclient.MovieDatabaseServlet.doGet(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:667)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:702)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:250)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)

    For EntityOne and EntityTwo you can just define a normal OneToMany mapping using the foreign key.
    Are you using JPA, or the TopLink API? JPA requires a mappedBy for the OneToMany, so this may be more difficult. You should be able to just add a JoinColumn on the OneToMany and make the column insertable/updateable=false.
    For the attachment, you could either map the foreign key as a Basic (DirectToFieldMapping) and maintain it in your model, or use a VariableOneToOne mapping in TopLink (this will require the entities share a common interface).
    James : http://www.eclipselink.org : http://en.wikibooks.org/wiki/Java_Persistence

  • One to Many with multiple tables on One side and one table on Many side

    Sorry for the confusion in the title. Here is my question. In my program, I have 2 different tables which store 2 different type of entities. Each one of entities has a list of attachments which I stored in a common attachment table. There is a one-to-many relationship between entity tables and attachment table.
    ENTITY_ONE (
    ID
    NAME
    ENTITY_TWO (
    ID
    NAME
    ATTACHMENTS (
    ID
    ENTITY_ID
    ATTACHMENT_NAME
    ENTITY_ID in ATTACHMENTS table is used to link attachments to either entity one or entity two. All IDs are generated by one sequence. So they are always unique. My question is how I could map this relationship into EntityOne, EntityTwo and Attachment JAVA class?

    For EntityOne and EntityTwo you can just define a normal OneToMany mapping using the foreign key.
    Are you using JPA, or the TopLink API? JPA requires a mappedBy for the OneToMany, so this may be more difficult. You should be able to just add a JoinColumn on the OneToMany and make the column insertable/updateable=false.
    For the attachment, you could either map the foreign key as a Basic (DirectToFieldMapping) and maintain it in your model, or use a VariableOneToOne mapping in TopLink (this will require the entities share a common interface).
    James : http://www.eclipselink.org : http://en.wikibooks.org/wiki/Java_Persistence

  • Unidirectional one-to-many with join table

    According to http://docs.jboss.org/hibernate/orm/3.5/reference/en-US/html/associations.html#assoc-unidirectional-12m "A unidirectional one-to-many association on a foreign key is an unusual case, and is not recommended", instead they recommend using a join table, e.g.
    create table Person ( personId bigint not null primary key )
    create table PersonAddress ( personId not null, addressId bigint not null primary key )
    create table Address ( addressId bigint not null primary key )
    However if doing this, when using SQLDeveloper the Address table does not appear as a child table of Person, which it should be as a unidirectional one-to-many meaning that I can't create a cache group for Person and subsequently Person.
    Is this something that can be worked around as I'm using a legacy schema created from Hibernate/JPA and the implications of changing are quite substantial?
    Thanks

    Hi Gennady,
    Apologies but my question was not clear enough. The schema structure that I have inherited is as follows:
    CREATE TABLE T_PERSON ( PERSONID NUMBER PRIMARY KEY, PERSONFIRSTNAME VARCHAR2(20), PERSONLASTNAME VARCHAR2(20) );
    CREATE TABLE T_PERSONADDRESS (PERSONID NUMBER NOT NULL, ADDRESSID NUMBER NOT NULL PRIMARY KEY );
    CREATE TABLE T_ADDRESS ( ADDRESSID NUMBER  PRIMARY KEY, ADDRESSTEXT VARCHAR2(200) );
    ALTER TABLE T_PERSONADDRESS ADD CONSTRAINT FK_PERSON_ADDR_PERSON_ID FOREIGN KEY (PERSONID) REFERENCES T_PERSON(PERSONID);
    ALTER TABLE T_PERSONADDRESS ADD CONSTRAINT FK_PERSON_ADDR_ADDR_ID FOREIGN KEY (ADDRESSID) REFERENCES T_ADDRESS(ADDRESSID);This is implementing a unidirectional one-to-many relationship between T_PERSON and T_ADDRESS according to the Hibernate and JPA recommendation. As far as I can see most schema designers would do this using by adding a column "PERSON_ID" (and associated FK) on the T_ADDRESS table and therefore not needing the T_PERSONADDRESS table.
    This being what it is, I would then like to create a cache-group as follows:
    CREATE READONLY CACHE GROUP "CACHEGROUPADDRESSES"
    AUTOREFRESH MODE INCREMENTAL INTERVAL 5 MINUTES
    STATE PAUSED
    FROM
      "SCHEMA1"."T_PERSON" (
        "PERSONID"        NUMBER            NOT NULL,
        "PERSONFIRSTNAME" VARCHAR2(20 BYTE),
        "PERSONLASTNAME"  VARCHAR2(20 BYTE),
        PRIMARY KEY("PERSONID")
      "SCHEMA1"."T_ADDRESS" (
        "ADDRESSID" NUMBER NOT NULL,
        "ADDRESSTEXT" VARCHAR2(20 BYTE),
        PRIMARY KEY("ADDRESSID")
      "SCHEMA1"."T_PERSONADDRESS" (
        "PERSONID"  NUMBER NOT NULL,
        "ADDRESSID" NUMBER NOT NULL,
        PRIMARY KEY("ADDRESSID"),
        FOREIGN KEY("PERSONID")
          REFERENCES "SCHEMA1"."T_PERSON"("PERSONID"),
        FOREIGN KEY("ADDRESSID")
          REFERENCES "SCHEMA1"."T_ADDRESS"("ADDRESSID")
      )This however gives me the error "TT8222: Multiple parent tables found" because TimesTen has failed to identify the one-to-many-using-link-table pattern.
    Without a schema re-write is there anything that I can do, alternatively will this be looked at for a future release of TimesTen?
    Edited by: TrisStev on Apr 16, 2012 10:37 AM

  • Need  one to many toplink+Jdeveloper tutorial with example

    Hi
    I need tutorial with example of one to many with Toplink+J developer
    Thanks
    Edited by: user11802935 on Aug 18, 2009 1:06 PM

    Hi,
    The following links should get you started.
    EclipseLink JPA + Eclipse
    http://wiki.eclipse.org/EclipseLink/Examples/JPA
    JDeveloper tutorials
    http://www.oracle.com/technology/products/jdev/index.html
    TopLink + JDeveloper tutorial
    http://www.oracle.com/technology/obe/obe11jdev/bulldog/ejb_jpa_jsf/ejb.html
    @OneToMany documentation
    http://wiki.eclipse.org/Introduction_to_EclipseLink_JPA_%28ELUG%29#.40OneToMany
    thank you
    /michael
    www.eclipselink.org

  • One-to-many mapping and update the many part

    Hello !
    Here's my problem,
    I've got an object A having a vector of object B.
    The mapping in toplink is one-to-many with the back-references set in B.
    Insertion : no problem.
    Now i would like to change the Vector of B (inserting new B, updating existing B) in a function with the Vector vC (modified vector of B).
    What is the best way to do this ?
    I tried many thing but either I have toplink 6004 error, or doing it by removing all elements of the Vector (deleting all B in database), and then setting A with C (recreating all object in the modified Vector).
    Another way to explain my case:
    how to do this in UnitOfWork ?
    function modifyAVectorOfB(A, vectorOfC)
    AClone = uow.registerObject(A);
    Aclone.setVectorOfB(vectorOfC);
    uow.commit;
    (and in database all existing object in C are updated, new object in C are created, removed object in C are deleted)

    Have found a solution, read all object in the modified Vector, read the modified object in the Unit Of Work with readObject(B) (So i get the database or cache version) and then comparing it with the modified to change what is needed to be change.

  • 3 way one-to-many through a single link table

    I have 3 tables that are linked through one to many relationships in a single link table. Here's the real relationships:
    assay(id)
    multiplex(id, assays)
    markerset(id, assays, multiplexes)
    Here's the database schema:
    assay(id, name)
    markerset(id, name)
    multiplex(id, name)
    assay_marker_set(assay_id[not null], marker_set_id[not null], multiplex_id[nullable])
    I've mapped one-to-many relationships between markersets and assays, and multiplexes and assays, and BOTH of these one-to-manys need to be writable. In the record creation process, assays are associated with markersets, and then assays are associated with multiplexes, which in turn are associated with markersets.
    Here's our dilemma. When committing multiplexes through a unit of work, the one-to-many with assays can't see the one-to-many with markersets, so the commit fails because the markerset key is null.
    We've gotten around the problem by creating a postSave() method in markerset that writes multiplex changes once they are created. But again, in a unitofwork commit, saving a markerset fires the postSave() method, which writes assays and multiplexes that have not yet been written to the database.
    We've gotten around THAT by only turning on postSave() when creating multiplexes, not when associating assays with markersets.
    My question is, is there a more conventional approach to this problem? Clearly, the database needs to be reworked, but time constraints and the quantity of data to be curated makes changing the schema impossible. Or have we arrived at the most sensible solution to a ridiculous problem? Currently what we have works, it's just incredibly complicated, and nearly unmaintainable.
    Thanks for the time to even read this post, and mocking is permitted ;-)
    Paul Cooper
    GlaxoSmithKline US Bioinformatics

    Looks like your object model does not match your data model.
    From you object model you seem to have,
    Assay
    MarkerSet 1-m Assay, 1-m Multiplex
    Multiplex 1-m Assay
    From your data model you have,
    Assay 1-m AssayMarkerSetAssociation
    MarkerSet 1-m AssayMarkerSetAssociation
    Multiplex 1-m AssayMarkerSetAssociation
    AssayMarkerSetAssociation 1-1 Assay, 1-1 MarkerSet, 1-1 Multiplex
    (your object model seems to be also missing the name)
    I'm not exactly sure how you have your mapping working, but it would seem the best solution is to introduce an AssayMarkerSetAssociation object into your object model.
    If you do not wish to use this object in your model, you could just use it internally to store the relationship and still have get/set methods for the relationships that you want that initialize themselves from the associations.
    So your object model would be,
    Assay
    MarkerSet 1-m AssayMarkerSetAssociation (+ getAssays, getMultiplexes methods)
    Multiplex 1-m AssayMarkerSetAssociation (+ getAssays, method)
    AssayMarkerSetAssociation 1-1 Assay, 1-1 MarkerSet, 1-1 Multiplex
    In general you seem to be able to get your mapping working without changing your object model, but are probably better off for maintainability to change your model slightly.

  • Struggling with a one to many relationship in a sub-report

    Post Author: Scott_tansley
    CA Forum: General
    I have a database schema as per below: tblENQUIRY                 tblDatasheets                  tblReportParasIRSID (PK)       1 --> &  IRSID (FK)                       UID (PK)Attribute1                     SHEETID (PK)     1 > &  SHEETID (FK)Attribute2                     Attribute1                         LIST_ORDER                         tblStandardParasAttribute3                     Attribute2                         PARA_CODE (FK)    & < 1   CODE     (PK)etc...                            Attribute3                                                                     TEXT                                   etc...
    The PROBLEM I am a Crystal Reports Newbie, and having to work through things bit by bitu2026  I've managed to achieve quite a lot, but I'm totally stuck with this and would appreciate some help. I need to create a report (essentially a letter and some datasheets) around a one-to-many relationship, which I have managed to compile using a main report (for the one &#91;tblENQUIRY&#93;) and sub report (for the many &#91;tblDatasheets&#93;).  Essentially I need a covering letter, then the u2018manyu2019 datasheets, and then a number of other pages (which are largely static text). I have created a main report which includes the covering letter, holds a subreport for the datasheets, and then contains the text for the additional pages.  This all works fine, and I get the correct number of datasheets for each main report. My problem stems from the use of this sub report.  This sub-report needs to hold some attribute values for each datasheet, which is fine.  However, on each datasheet page I need to have some paragraphs, which are held in another one to many relationship.  Each datasheet may have up to six paragraphs held as a code in tblReportParas, with a relationship to the text as held in tblStandardParas. My original thought would have been to embed another sub report, containing the values from tblStandardParas!TEXT, into the first sub report.  However, I have found that it is not possible to have a sub-report inside another sub-report.  I had seperated the first sub-report out from the main report, and then embedded another sub-report into it.  This worked fine until I tried to stitch the sub-report back into the main report (at which point the sub-sub-report dissapeared from view). I have therefore reworked my sub-report a little, and the attribution is now stored in a pageheader, with the tblStandardParas!TEXT in a detail section below it.  This almost works! The only problem is that there is no relationship between the pageheader and detail sections.  To clarify, I would expect to have one datasheet, with the attribution at the top, and then the six paras below.  Then, the same on the next page (assuming there is a second datasheet) for that report.  Instead, I get the correct attribution, but the detail section actually gives every paragraph in the database, no matter which datasheet/or report it related to!  I therefore need to limit the detail section to only show those paragraphs where the SHEETID in tblReportParas is the same as the tblDatasheets SHEETID. Any offers of advice would be appreciated.

    Post Author: Scott_tansley
    CA Forum: General
    I managed to resolve this myself in the end.  I moves the tblEnquiry data into report header/footer sections, this allowed me to add the tblDatasheets information into the details section, which gave me multiple pages - and then finally, the Paragraphs were added through the use of a sub report. 
    There's probably an even better way, but for now it works, it's quick - and so I'm going to go with it!
    Thanks for your interest.

  • Help with multi-table mapping for one-to-many object inheritance

    Hi,
    I have posted on here before regarding this (Toplink mapping for one-to-many object inheritance but I am still having problems mapping my object model to my schema.
    Object model
    The Person and Organisation objects contain base information and have the primary keys person_id and organisation_id. It is important that there is no duplication of person and organisation records, no matter how many times they are saved in different roles.
    There are two types of licenceholder in the problem domain, and the ILicenceHolder interface defines information and methods that are common to both. The PersonalLicenceHolder object represents one of these types of licenceholder, and is always a person, so this class extends Person and implements ILicenceHolder.
    The additional information and methods that are required by the second type of licenceholder are defined in the interface IPremisesLicenceHolder, which extends ILicenceHolder. Premises licence holders can either be people or organisations, so I have two objects to represent these - PremisesLicenceHolderPerson which implements IPremisesLicenceHolder and extends Person, and PremisesLicenceHolderOrganisation which implements IPremisesLicenceHolder and extends Organisation.
    The model is further complicated by the fact that any single Person may be both a PersonalLicenceHolder and a PremisesLicenceHolderPerson, and may be so several times over. In this case, the same basic Person information needs to be linked to several different sets of licenceholder information. In the same way, any single Organisation may be a PremisesLicenceHolderOrganisation several times over.
    Sorry this is complicated!
    Schema
    I have Person and Organisation tables containing the basic information with the primary keys person_id and organisation_id.
    I have tried to follow Donald Smith's advice and have created a Role table to record the specialised information for the different types of licence holder. I want the foreign keys in this table to be licenceholder_id and licence_id. Licenceholder_id will reference either organisation_id or person_id, and licence_id will reference the primary key of the Licence table to link the licenceholder to the licence. Because I am struggling with the mapping, I have changed licenceholder_id to person_id in an attempt to get it working with the Person object before I try the Organisation.
    Then, when a new licenceholder is added, if the person/organisation is already in the database, a new record is created in the Role table linking the existing person/organisation to the existing licence rather than duplicating the person/organisation information.
    Mapping
    I am trying to use the toplink mapping workbench to map my PremisesLicenceHolderPerson object to my schema. I have mapped all inherited attributes to superclass (Person). The primary table that the attributes are mapped to is Person, and I have used the multi-table info tab to add Roles as an additional table and map the remaining attributes to that.
    I have created the references PERSON_ROLES which maps person.person_id to roles.person_id, ROLES_PERSON which maps roles.person_id to person.person_id and ROLES_LICENCE which maps roles.licence_id to licence.licence_id.
    I think I have put in all the relationships, but I cannot get rid of the error message "The following primary key fields are unmapped: PERSON_ID".
    Please can somebody tell me how to map this properly?
    Thank you.

    I'm not positive about your mappings, but it looks like the Person object should really have a 1:M or M:M mapping to the Licenceholder table. This then means that your object model should be similar, in that Person object could have many Licenses, instead of being LicenceHolders. From the looks of it, you have it set up from the LicenceHolder perspective. What could be done instead if a LicenceHolder could have a 1:1 reference to a person data object, rather than actually be a Person. This would allow the person data to be easily shared among licences.
    LicenceHolder1 has an entry in the LicenceHolder table and Person table. LicenceHolder2 also has entries in these tables, but uses the same entry in the Person table- essentially it is the same person/person_ID. If both are new objects, TopLink would try to insert the same person object into the Person table twice. I'm not sure how you have gotten around or are planning to get around this problem.
    Since you are using inheritance, it means that LicenceHolder needs a writable mapping to the person.person_id field- most commonly done through a direct to field mapping. From the description, it looks like roles.person_id is a foreign key in the multiple table mapping, meaning it would be set based on the value in the person.person_id field, but the person.person_id isn't actually mapped in the object. Check to make sure that the ID attribute LicenceHolder is inheriting from person hasn't been remapped in the LicenceHolder descriptor to a different field.
    Best Regards,
    Chris

  • SSAS 2008 snowflake - dimensions with one-to-many relationship (NOT fact table) and hierarchy?

    Hi, below is my data model for SSAS 2008 on snowflake schema.
    Below is SQL Server DW tables:
    DimStudent - StudentID [primarykey], StudentName, DateOfBirth, AddressID
    DimStudentAddresses - AddressID [primarykey], StudentID [foreignkey], ddressLine1, AddressLine2, AddressType
    FactEnrolment - StudentID, EnrolWeek, EnrolFees
    So here FactEnrolement.StudentID is joined to DimStudent.StudentID column,
    and relationship between DimStudent & DimeStudentAddresses is one to many I.e. one student can have multiple addresses like primary or secondry address.
    To design snowflake schema in SSAS 2008 BIDS project :
     [Question-1] how to join one-to-many dimensions (NOT fact table) Like DimStudent & DimAddresses?
     [Question-2] At the end I want to have a single dimension only I.e. Student which should have both DimStudent & DimStudentAddresses tables attributes init. So I can create hierarchy from these two table into a single dimension? How
    to do this?
    Please reply with feedback particular to my above scenario as I refereed other MSDN forums but nothing solid I found.
    Any STEP-BY-STEP guideline please. Many thanks.

    Hello KM,
    Have you solved this issue after refer to Bill's suggestion? Please let us know how things go.
    If you have any feedback on our support, please click
    here.
    Best Regards,
    Elvis Long
    TechNet Community Support

  • One-to-many relationship: problem with several tables on the one side...

    Hello
    I'm having problems developing a database for a content management system. Apart from details, I've got one main table, that holds the tree structure of the content ("resources") and several other tables that contain data of a particular datatype ("documents", "images", etc.). Now, there's one-to-many relationship between "resources" table and all the datatype tables - that is, in the "resources" table there's "resource_id" column, being a foreign key referenced to the "id" columns in the datatype tables.
    The problem is that this design is deficient. I can't tell form the "resource_id" column from which datatype table to get the data. It seems to me that one-to-many relationship only works with two tables. If the data on the one side of the relationship is contained in several tables, problems arise.
    Anybody knows a solution? I would be obliged.
    Regards
    Havocado

    Hi;
    A simple way may be create a view on referenced tables:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL>
    SQL> drop table resources;
    Table dropped
    SQL> create table resources(id number, name varchar2(12));
    Table created
    SQL> insert into resources values(1,'Doc....');
    1 row inserted
    SQL> insert into resources values(2,'Img....');
    1 row inserted
    SQL> drop table documents;
    Table dropped
    SQL> create table documents(id number, resource_id number,type varchar2(12));
    Table created
    SQL> insert into documents values(1,1,'txt');
    1 row inserted
    SQL> drop table images;
    Table dropped
    SQL> create table images(id number, resource_id number,path varchar2(24));
    Table created
    SQL> insert into images values(1,2,'/data01/images/img01.jpg');
    1 row inserted
    SQL> create or replace view vw_resource_ref as
      2    select id, resource_id, type, null as path from documents
      3      union
      4     select id, resource_id, null as type, path from images;
    View created
    SQL> select * from resources r inner join vw_resource_ref rv on r.id = rv.resource_id;
            ID NAME                 ID RESOURCE_ID TYPE         PATH
             1 Doc....               1           1 txt         
             2 Img....               1           2              /data01/images/img01.jpg
    SQL> Regards....

  • One-to-Many implemented with a join Table

    Hello,
    Is it possible to implement a One-to-Many relationship with a join table, just like
    the Reference Implementation does.
    Regards,
    Jeroen

    "Jeroen Ferdinandus" <[email protected]> wrote in
    news:[email protected]:
    Is it possible to implement a One-to-Many relationship with a join
    table, just like the Reference Implementation does.Not with our CMP, you will have to resort to BMP for that.
    Cedric

  • One to Many Mapping with different SQL types

    We have an interesting one to many relationship in our system in which the source and target field SQL types do not match, but the values do. The relationship is actually between multiple entries in the same database table. So, imagine we have some table that looks sort of like this:
    KEY ObjectID OwnerNo
    100 1234     0
    101 ABCD     1234
    102 EFGH     1234ObjectID is defined as a varchar type, but Parent entries are guaranteed to have integer value ObjectIDs. Child entries point to the parent through the OwnerNo field, which defined in the database as a numeric.
    A simple one-to-many mapping will give you the following SQL error on execution: [SQL0401] Comparison operator = operands not compatible.
    I tried modifying my descriptor after load as follows:
       public static void modifyOneToMany(Descriptor descriptor)
           ExpressionBuilder builder = new ExpressionBuilder();
           Expression exp = builder.getField("OwnerNo").
              equal(builder.getField("ObjectID").toNumber());
           descriptor.getMappingForAttributeName("children")
              .setSelectionCriteria(exp);
       }But this introduces two problems in the generated SQL ( ... WHERE ((t0.OwnerNo = TO_NUMBER(t0.ObjectID) ... ). First, this generates a where clause using the function TO_NUMBER, which is not supported by DB2 on AS400, our database platform. Second, the table reference is off in the generated SQL--I couldn't find a way to specify that the right hand side of the = operator should be from the parent of the one to many mapping--both sides are referenced from the child context (t0).

    I found the getFunction() method on Expression, so I can solve half of this problem with the following code:
       public static void modifyOneToMany(Descriptor descriptor)
         if (descriptor.getMappingForAttributeName("children").isOneToManyMapping())
           OneToManyMapping map = (OneToManyMapping) descriptor.
                                  getMappingForAttributeName("children");
           DatabaseField objectID= (DatabaseField) map.getSourceKeyFields().get(0);
           DatabaseField ownerNo = (DatabaseField) map.getTargetForeignKeyFields().get(0);
           ExpressionBuilder builder = new ExpressionBuilder();
           Expression exp = builder.getField(ownerNo).getFunction("CHAR").
                            equal(builder.getField(objectID));
           map.setSelectionCriteria(exp);
       }This generates the following where clause:
    ... WHERE ((CHAR(t0.OwnerNo) = t0.ObjectID) ...
    But, I still have two questions:
    1. How do we get the right hand side of this comparison to reference the Parent part of the 1-M mapping?
    2. Since character and numeric conversions are pretty standard SQL functions, is there something wrong with the DB2 database platform I'm using?

  • Understanding objects relations one-to-many and many-to-many with flex4

    Hello, I'm a newbie on Flex 4.
    I read several examples and also the "one week training". What I couldn't find is how to manage relations among objects.
    I understood that objects coming from the server must be translated to value objects.
    Because I'm working with Spring, Hibernate and BlazeDS, I've several beans and relations defined with the annotations @OneToMany and @ManyToMany. These relations are managed using List, Set and Map objects.
    More precisaly, I've to create a flex datagrid, each row is an "author" objects. Cliccking a row, I need to load some other related objects (let's call them "documents").
    Auhtor and Documents objects are in a one-to-many relation.
    My questions are:
    1) Which is the correct way to handle related objects in Flex? This questions arise from the fact that there are two ways in order to manage such objects. The first is to load the parent object and them call related method in order to get child. For example author.getDocuments(). I get all the related objects (author+ all his documents) with just one call, the one to load the "author" object. BlazeDS doesn't support lazy loading.
    The second way, is to provide the parent ID to a method that loads the related objects. For example getDocuments(authorID). I need to make a query for each ID
    Obviously, the value objects we have to create with AS are different. In the first case, the author VO will have a ArrayCollection in order to manage documents.In the second case I'll not create this property.
    2) In Flex, which is the best way? is it possible to manage objects (documents) of objects (authors) with MXML?
    3) More in general, Flex experts people, what are used to do? Where I can find an example?
    Thank you
    Paolo

    Thank you Pablo.
    Regarding my question n.2, it is confused.
    Here what I meant:
    Let's suppose I work with VO and ArrayCollection (the first "way" I wrote above). To get "Documents" objects, I need to call author.getDocuments().
    Now, I'm not sure that I'm able to do the same with MXML and that is is the easiest way. I think it should be easier working with "Documents" object instead of Auhors in order to work with Documents.
    For example, in order to get autors I can write a CallResponder and use a token. To fill a datagrid I define a method like
    protected function dataGrid_creationCompleteHandler(event:Flex:Event):void
         getAuthorsResult.token = auhtorService.getAuthors();}
    Now in order to fill the grid, I can use  for example <mx:DataGridColumn dataField="lastname">. Very easy and clear.
    But now, if I need to extract the Document objects and visualize them inside anothee DataGrid, I don't know how to do.
    For example, in <mx:DataGridColumn> tag what I've to write in order to visualize a Document property, using an Author object?
    Fixing an Auhtor, I need to loop over each Documents, but how can I loop inside the MXML? Something like <mx:DataGridColum dataField="author.documentloopvariable....>
    It should be better to get Documents via a method like getDocuments(authorID). Now I get a token related to a CallResponder, and I can work at the same manner as the Author. Isn't it? But this is the second "way" I wrote above.
    Well, I hope my question in a little clear.
    thank you
    Pbesi

  • JPA: Issue with loading One To Many relation

    Hi All,
    I have a One to Many relation mapped as below
    @Entity
    @Table(name="ACCOUNT_TABLE")
    public class UserAccount {
         // Attributes
         @Id
         @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="USER_SEQ")
         @SequenceGenerator(name="USER_SEQ", sequenceName="USERS_SEQ",allocationSize=1)
         @Column(name="CLIENT_ID")
         private Long clientId;
         @Column(name="USER_ID")
         private String userId;
         @OneToMany(fetch=FetchType.LAZY, mappedBy="userAccount")
         @JoinColumn(name="USER_ID", referencedColumnName="USER_ID", insertable=false, updatable=false)
         private List<UserRole> assignedRoles;
    @Entity
    @Table(name = "ROLE_TABLE")
    public class UserRole extends BaseEntity implements Serializable {
         private static final long serialVersionUID = -1651953276532642312L;
         @Id
         @Column(name = "USER_ID", length = 30, nullable=false, insertable=false, updatable=false)
         private String userId;
         @Column(name = "BUSINESS_CODE", length = 10, nullable=false, insertable=false, updatable=false)
         private String businessCode;
         @Column(name = "ROLE_NAME", length = 30, nullable=false, insertable=false, updatable=false)
         private String roleName;
         @ManyToOne()
         @JoinColumn(name="USER_ID", referencedColumnName="USER_ID", insertable=false, updatable=false)
         private UserAccount userAccount;
    As you may have noticed, the tables are not joined on the Primary key of parent. This is legacy schema and I have to work with it.
    Account and Role are joined by the USER_ID column. This I specified by providing JoinColumn.
    Then I have a DAO to retrieve the relation based on user id.
    public class UserAccountDAOJPAImpl UserAccountDAO{
         private static final String USER_ACCOUNT_BY_USERID = "select distinct ua " +
         "from UserAccount ua " +
         "left outer join fetch ua.assignedRoles ar " +
         "where ua.userId = ?1 ";
         public UserAccount findByUserName(String userName){          
              UserAccount userAccount=null;
              List<UserAccount> userAccounts =null;
         Query query = this.entityManager.createQuery(USER_ACCOUNT_BY_USERID);
         query.setParameter(1, userName.toUpperCase());
         userAccounts = query.getResultList();
         if(!userAccounts.isEmpty()) {
              userAccount=userAccounts.get(0);
              return userAccount;
    When I test this code ( for the user Id I used in test there are 11 roles )
    The SQL generated is correct, when I run the SQL in PL/SQL Developer, it returns the results as expected.
    But the DAO method above returns one UserAccount object with List of 11 UserRole objects as expected. But all of these 11 UserRole objects are same, where as the query returns 11 different roles.
    I couldn't figure out what I was doing wrong.
    Any help is appreciated.
    thanks,
    Raghavan

    @OneToMany(fetch=FetchType.LAZY, mappedBy="userAccount")
    @JoinColumn(name="USER_ID", referencedColumnName="USER_ID", insertable=false, updatable=false)
    private List<UserRole> assignedRoles;
    }What do you get when you remove this @JoinColumn annotation? It shouldn't be necessary. (user_id seems a little suspect as the join column name by the way, I would have expected role_id here...)

Maybe you are looking for

  • Convert color to float

    Hello! I�m using a JColorChooser to pick a color and I wanted to convert this value in a float. Using : Color color = Painel_cores.getColor(); float[] myColor = { color.getRed(), color.getGreen(), color.getBlue() }; I get trash that can�t be used� Us

  • Airport base station and U Verse

    Does anyone know how to get an Airport Base Station to connect wirelessly to an ATT U VERSE 2 WIRE modem? I've used Airport Utility to get the Base Station to join my network but it never finds the ATT network. Thank you, Charlie

  • [38133] The Logical Table [...] is not joined to any other logical table.

    Hi all! I'm very new to Oracle BI EE. My need is to create my first report in BI. I've opened Oracle BI Administration Tool, created new repository, added physical tables, created new item named "reports" in "Business Model and Mapping" section, made

  • Security for Dunces

    I'm working on a pdf for limited distribution.  It appear that my options for securing a pdf is limited to this (using only Acrobat software): 1) password protecting it (1 or 2 levels depending on whether or not I want people to be able to fill out f

  • Substation in Shopping cart..

    Hello Friends,     Is there any SRM SC n-step workflow does have susbtation concept?..    Please give me some hints..   Thanks,   John.