-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi,
openjpa has still a problem with constant joins. [1] I thought, addind constant field to one class could be a quick work around, but obviously I have some mistake in my join (I am quite new to JPA), or there is a bug in jointable. I have 1 : M mapping between 1 device (class name: Device) and M tempeartueStamps (class name: TempStemp) I have a primary key and 4 different lists in Device: @Id private Integer did; @OneToMany(mappedBy="stampOwner", cascade = CascadeType.ALL,fetch=FetchType.LAZY) @JoinTable(name="TEMPSTAMP", joinColumns={ @JoinColumn(name="STAMPOWNER_DID", referencedColumnName="DID"), @JoinColumn(name="TEMPSTAMP.TEMPTYPE", referencedColumnName="OUTGING") }) private List<TempStamp> tempOutgoingList; // similar other three lists but with other constant The mapped object/table "TEMPSTAMP" consitss of: - -Temptype - -TempValue - -TempTime - -stampOwner As suggested in [2] my second join in other table is join with constant Because of [1] workaround, in device I add also the constants: private String outgoing="'outgoing'"; When device and its lists get persisted, all database entries are correct. Problem is with retrieving. Suppoose I have device with 4 lists with n elements each different values. When retrieving devices with a TypedQuery, I always end up, with 4 elements in each list having all the same value. This is really weird and I have no clue why this happens. I also tried without success: @JoinColumn(name="TEMPSTAMP.TEMPTYPE", referencedColumnName="DEVICE.OUTGING") Another non-critical thing I wondered is a issue with merge(): suppose I have a list of devices: List<Device> runtimeList; // I retrieve its objects with: TypedQuery<Device> dQuery = em.createQuery("select d from Device d", Device.class); when running merge/persitance I iterate over that list and use: EntityTransaction tx = em.getTransaction(); tx.begin(); for(Device dSaved : runtimeList){ Device dfound = em.find(WRG.class, savedDevice.getId()); if (dfound != null) { dSaved = em.merge(dfound); } else { em.persist(dSaved); } } tx.commit(); Now, when I would run em.merge(dSaved) instead of em.merge(dFound) I get the Error: "An object of type <X> with oid <Y> already exists in this context another cannot be persisted" I cannot comprehend that. Stack trace clearly shows that em.merge fails to save the same object. Well I am fairly new to JPA, I found some hint that I would need to "detach" the object before merging it. Any help much appreciated, greetings, Adam [1] https://issues.apache.org/jira/browse/OPENJPA-2054 [2] http://people.apache.org/~mikedd/nightly.builds/apache-openjpa-2.3.0-SNAPSHOT/docs/docbook/manual/ref_guide_mapping_notes_nonstdjoins.html -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAlEKjhgACgkQefEEI87R1DcKwQCggFOOTxffz3QPGgl1HWuyU0SF fZ8AoKEhk+J+q8O0mESMtTERiwvOoKSp =d5Az -----END PGP SIGNATURE-----