[EJB 3.0] - NonUniqueObjectException
by kvbisme
OK, this is too common a scenario to be this confusing.
I have two tables in a database, we will call them Table A and Table B
Table A has an ID field as the primary key and other information
Table B has a composite key of three fields ? let?s call them column B1, B2, and B3 and of course other information.
The relationship of the tables is that an entity in Table A can point to zero or more entities in Table B. And multiple entries in Table A can reference the same entity in table B
Table B knows nothing about Table A.
I have to create my own tables (using the @Table) to appease the DBA. Anyway, I create a join table ? lets call it A_Joins_B with columns ID, B1, B2, and B3.
In my Entity Bean I have:
@OneToMany (cascade=CascadeType.ALL, fetch=FetchType.LAZY)
@JoinTable (name=?A_joins_B?, joinColumns=@JoinColumn(name=?ID?), inverseJoinColumns={@JoinColumn(name=?B1?), @JoinColumn(name=?B2?), @JoinColumn(name=?B3?)}
(p.s. I did try a @ManyToMany as well with the same results)
As soon as I receive a series of records to update ( they arrived batched up in a big collection ) I iterate through the collection, convert each to an entity bean, and then attempt to merge them into the database with the em.merge(obj);
This works until I encounter an update that contains a B entity that has already been referenced by a previous A entity. Then I get the org.hibernate.NonUniqueObjectEception with a message of:
?a different object with the same identifier value was already associated with the session: [org.myexample.entity.B#org.myexample.entity.key.B_PrimaryKey@44 ]?
What am I missing?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993985#3993985
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993985
19 years, 5 months
[JBoss jBPM] - Re: 3.2alpha2 unable to load process archives
by dhartford
actually, looking further down the trace I'm gonna go check out a couple of things
| ....
| Caused by: java.lang.ClassCastException: org.jbpm.graph.def.Node_$$_javassist_59
| at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:126)
| at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:48)
| at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:379)
| at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3388)
| at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:255)
| at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:189)
| at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:101)
| at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
| at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
| at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
| at org.hibernate.type.EntityType.resolve(EntityType.java:303)
| at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
| at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
| at org.hibernate.loader.Loader.doQuery(Loader.java:717)
| at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
| at org.hibernate.loader.Loader.doList(Loader.java:2144)
| at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
| at org.hibernate.loader.Loader.list(Loader.java:2023)
| at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
| at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
| at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
| at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
| at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
| at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:780)
| at org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:153)
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993983#3993983
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993983
19 years, 5 months
[JBoss Seam] - Re: [OT] Seam and Tomahawk - lost property?
by SmokingAPipe
"gavin.king(a)jboss.com" wrote : I mean, you are free to do what you like. Use Tomahawk, please, that's totally up to you. But if you choose to not take our well-meaning advice, then don't you think its unreasonable to expect us to support your decision by answering lots of forum questions?
In fact it's perfectly reasonable for you to not answer any forum questions. You've already provided a fantastic free open-source framework. That's not required or expected of you. Answering questions on a forum is even less required or expected. We should be happy to get expert-level advice like this on a forum.
As for Tomahawk, I have seen Gavin's (and others) repeated posts that say, "don't use it." I used it and it got me on the wrong track, and now I'm having to spend time ripping it out because it's just not working. The scoop is Icefaces will work with Seam, and Icefaces has some way cooler features than Tomahawk anyway, so after I get my app up and running I'm going to start adding some Icefaces to it.
It's too bad about Tomahawk because it does have some nice things, especially the sortable tables, but it's too painful to make it work.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993980#3993980
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993980
19 years, 5 months