[EJB 3.0] - Bug with Compound Id that include a relathionship
by siaroga
Hey guys,
I've found a bug in the "Compound Primary Keys" implementation in JBoss/Hibernate EJB3. I've been able to reproduce this problem on JBoss 4.0.4GA and jboss-EJB-3.0_Embeddable_ALPHA_9. Current implementation generates extra field from compound key. This is an example from Sun's "The Java EE 5 Tutorial" http://java.sun.com/javaee/5/docs/tutorial/doc/PersistenceEJB2.html
| @IdClass(order.entity.LineItemKey.class)
| @Entity
| @Table(name = "EJB_ORDER_LINEITEM")
| public class LineItem {
| @Id
| public int getItemId() {
| return itemId;
| }
| @Id
| @Column(name="ORDERID", nullable=false, insertable=false, updatable=false)
| public Integer getOrderId() {
| return orderId;
| }
| }
|
| public final class LineItemKey implements java.io.Serializable {
|
| private Integer orderId;
| private int itemId;
| ...
| public Integer getOrderId() {
| return orderId;
| }
| ...
| }
|
This generates following SQL in logs:
| DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Snapshot select: select lineitem_.orderId, lineitem_.itemId, lineitem_.ORDERID as ORDERID9_, lineitem_.quantity as quantity9_, lineitem_.VENDORPARTNUMBER as VENDORPA4_9_ from EJB_ORDER_LINEITEM lineitem_ where lineitem_.orderId=? and lineitem_.itemId=?
| DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Insert 0: insert into EJB_ORDER_LINEITEM (ORDERID, quantity, VENDORPARTNUMBER, orderId, itemId) values (?, ?, ?, ?, ?)
| DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Update 0: update EJB_ORDER_LINEITEM set ORDERID=?, quantity=?, VENDORPARTNUMBER=? where orderId=? and itemId=?
| DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Delete 0: delete from EJB_ORDER_LINEITEM where orderId=? and itemId=?
|
| OR
|
| insert into EJB_ORDER_LINEITEM (ORDERID, quantity, VENDORPARTNUMBER, orderId, itemId) values (?, ?, ?, ?, ?)
|
As you can see there are duplicationg columns: ORDERID from LineItem class and orderId from LineItemKey.
When I add @Column annotation to the LineItemKey:
| public final class LineItemKey implements java.io.Serializable {
|
| private Integer orderId;
| private int itemId;
| ...
| @Column(name="ORDERID", nullable=false, insertable=false, updatable=false)
| public Integer getOrderId() {
| return orderId;
| }
| ...
| }
|
I got exception:
| org.hibernate.MappingException: Repeated column in mapping for entity: order.entity.LineItem column: ORDERID (should be mapped with insert="false" update="false")
| at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:575)
|
I believe this is connected to Hibernate bug HBX-164 http://opensource.atlassian.com/projects/hibernate/browse/HBX-164
Should I file a bug to JBoss or Hibernate JIRA?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979240#3979240
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979240
19 years, 8 months
[EJB 3.0] - DLQhandler appears to have a bug fixed in other file version
by davidjterry
I get an exception:
17:53:14,937 WARN [DLQHandler] Message resent too many times; sending it to DLQ; message id=ID:3-11612186025461
17:53:14,937 ERROR [StdServerSession] session failed to run; setting rollback only
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:396)
at org.jboss.ejb3.mdb.DLQHandler.makeWritable(DLQHandler.java:357)
at org.jboss.ejb3.mdb.DLQHandler.sendMessage(DLQHandler.java:269)
at org.jboss.ejb3.mdb.DLQHandler.handleRedeliveredMessage(DLQHandler.java:228)
at org.jboss.ejb3.mdb.MDB$MessageListenerImpl.onMessage(MDB.java:1066)
at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:266)
at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:902)
at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)
at org.jboss.mq.SpySession.run(SpySession.java:323)
at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:194)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
at java.lang.Thread.run(Thread.java:595)
This bug is caused by using Hashtable instead of a HashMap for temp variable in makeWritable in DQLHandler.java. It was fixed already but not in MDB code see:
http://lists.jboss.org/pipermail/jboss-jira/2006-July/001285.html
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979232#3979232
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979232
19 years, 8 months
[JBoss Getting Started Documentation] - Bank example compile error.
by dream2732
I carefully followed the getting started guide (for version 4.0.3SP1) to the point where it says "compiling the java source"--environment variables, I believe are set up correctly, and I also pointed jboss.home to my local jboss installation directory, when I ran the ant command "ant -f jboss-build.xml compile", get the following error :
[javac] C:\Documents and Settings\powerpc\Desktop\ff_down\j2eetutorial14\
examples\bank\src\com\jboss\ebank\WSClient.java:15: package org.jboss.ws.jaxrpc
does not exist
[javac] import org.jboss.ws.jaxrpc.ServiceFactoryImpl;
[javac] ^
[javac] C:\Documents and Settings\powerpc\Desktop\ff_down\j2eetutorial14\
examples\bank\src\com\jboss\ebank\WSClient.java:16: package org.jboss.ws.jaxrpc
does not exist
[javac] import org.jboss.ws.jaxrpc.ServiceImpl;
[javac] ^
[javac] C:\Documents and Settings\powerpc\Desktop\ff_down\j2eetutorial14\
examples\bank\src\com\jboss\ebank\WSClient.java:31: cannot find symbol
[javac] symbol : class ServiceFactoryImpl
[javac] location: class com.jboss.ebank.WSClient
[javac] ServiceFactoryImpl factory = new ServiceFactoryImpl();
[javac] ^
[javac] C:\Documents and Settings\powerpc\Desktop\ff_down\j2eetutorial14\
examples\bank\src\com\jboss\ebank\WSClient.java:31: cannot find symbol
[javac] symbol : class ServiceFactoryImpl
[javac] location: class com.jboss.ebank.WSClient
[javac] ServiceFactoryImpl factory = new ServiceFactoryImpl();
[javac] ^
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 4 errors
Has anyone experienced this before? Any input is appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979230#3979230
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979230
19 years, 8 months