java.lang.ClassCastException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • import java.util.Set; public class TestA implements java.io.Serializable { private int a_id; private String testa; private Set b; public TestA() { } public int getA_id() { return this.a_id; } public void setA_id(int a_id) { this.a_id = a_id; } public String getTesta() { return this.testa; } public void setTesta(String testa) { this.testa = testa; } public Set getB() { return this.b; } public void setB(Set b) { this.b = b; } } public class TestB implements java.io.Serializable { private int b_id; private int ref_a; private String testb; public TestB() { } public int getB_id() { return this.b_id; } public void setB_id(int b_id) { this.b_id = b_id; } public int getRef_a() { return this.ref_a; } public void setRef_a(int ref_a) { this.ref_a = ref_a; } public String getTestb() { return this.testb; } public void setTestb(String testb) { this.testb = testb; } public String toString() { return b_id + ": " + testb; } public boolean equals(Object o) { if (!(o instanceof TestB)) return false; if ((b_id == ((TestB)o).getB_id()) && (ref_a == ((TestB)o).getRef_a())) return true; else return false; } } <hibernate-mapping > <class name="TestA" table="testa" node="testa"> <id name="a_id" type="int" unsaved-value="any" column="a_id" node="@a_id"/> <property name="testa" column="testa" node="testa"/> <set name="b" node="testb" embed-xml="true"> <key column="ref_a"/> <one-to-many class="TestB"/> </set> </class> </hibernate-mapping> <hibernate-mapping> <class name="TestB" table="testb"> <composite-id> <key-property name="b_id" type="int" column="b_id"/> <key-property name="ref_a" column="ref_a"/> </composite-id> <property name="testb" column="testb" node="testb"/> </class> </hibernate-mapping> import org.hibernate.cfg.Configuration; import org.hibernate.*; import org.dom4j.*; import org.dom4j.io.*; import java.util.*; public class Main { public Main() { } public static void main(String[] args) { Configuration cfg = new Configuration() .addClass(TestA.class) .addClass(TestB.class); SessionFactory factory = cfg.buildSessionFactory(); Session session4 = factory.openSession().getSession(EntityMode.DOM4J); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("testa"); Query query = session4.createQuery("from TestA as a"); for (Iterator it = query.iterate(); it.hasNext();) { Element e = (Element) it.next(); root.add(e); //TestA t = (TestA) it.next(); //System.out.println(t.getA_id()+t.getB().toString()); } } } Exception in thread "main" java.lang.ClassCastException: org.dom4j.tree.DefaultElement at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:279) at org.hibernate.pretty.MessageHelper.infoString(MessageHelper.java:68) at org.hibernate.engine.EntityKey.toString(EntityKey.java:77) at java.lang.String.valueOf(String.java:2577) at java.lang.StringBuffer.append(StringBuffer.java:220) at org.hibernate.util.StringHelper.toString(StringHelper.java:168) at org.hibernate.loader.Loader.getRow(Loader.java:762) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:295) at org.hibernate.loader.Loader.doQuery(Loader.java:389) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208) at org.hibernate.loader.Loader.loadCollection(Loader.java:1367) at org.hibernate.loader.collection.OneToManyLoader.initialize(OneToManyLoader.java:107) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1356) at org.hibernate.type.CollectionType.getCollection(CollectionType.java:470) at org.hibernate.type.CollectionType.resolveKey(CollectionType.java:328) at org.hibernate.type.CollectionType.resolve(CollectionType.java:322) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:494) at org.hibernate.loader.Loader.doQuery(Loader.java:413) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208) at org.hibernate.loader.Loader.loadEntity(Loader.java:1278) at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:141) at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:126) at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2491) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:386) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:367) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:166) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:119) at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:593) at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80) at org.hibernate.proxy.Dom4jLazyInitializer.getElement(Dom4jLazyInitializer.java:21) at org.hibernate.proxy.Dom4jProxy.target(Dom4jProxy.java:561) at org.hibernate.proxy.Dom4jProxy.getParent(Dom4jProxy.java:177) at org.dom4j.tree.AbstractElement.addNode(AbstractElement.java:2130) at org.dom4j.tree.AbstractElement.add(AbstractElement.java:1412) at Main.main(Main.java:27) Fetching data with default EntityMode (now commented out in class Main) works fine. (Tried also with H3 from CVS. Posted to forum, but no response in a week, so suppose to be a bug.)
    via by Martin Caslavsky,
  • import java.util.Set; public class TestA implements java.io.Serializable { private int a_id; private String testa; private Set b; public TestA() { } public int getA_id() { return this.a_id; } public void setA_id(int a_id) { this.a_id = a_id; } public String getTesta() { return this.testa; } public void setTesta(String testa) { this.testa = testa; } public Set getB() { return this.b; } public void setB(Set b) { this.b = b; } } public class TestB implements java.io.Serializable { private int b_id; private int ref_a; private String testb; public TestB() { } public int getB_id() { return this.b_id; } public void setB_id(int b_id) { this.b_id = b_id; } public int getRef_a() { return this.ref_a; } public void setRef_a(int ref_a) { this.ref_a = ref_a; } public String getTestb() { return this.testb; } public void setTestb(String testb) { this.testb = testb; } public String toString() { return b_id + ": " + testb; } public boolean equals(Object o) { if (!(o instanceof TestB)) return false; if ((b_id == ((TestB)o).getB_id()) && (ref_a == ((TestB)o).getRef_a())) return true; else return false; } } <hibernate-mapping > <class name="TestA" table="testa" node="testa"> <id name="a_id" type="int" unsaved-value="any" column="a_id" node="@a_id"/> <property name="testa" column="testa" node="testa"/> <set name="b" node="testb" embed-xml="true"> <key column="ref_a"/> <one-to-many class="TestB"/> </set> </class> </hibernate-mapping> <hibernate-mapping> <class name="TestB" table="testb"> <composite-id> <key-property name="b_id" type="int" column="b_id"/> <key-property name="ref_a" column="ref_a"/> </composite-id> <property name="testb" column="testb" node="testb"/> </class> </hibernate-mapping> import org.hibernate.cfg.Configuration; import org.hibernate.*; import org.dom4j.*; import org.dom4j.io.*; import java.util.*; public class Main { public Main() { } public static void main(String[] args) { Configuration cfg = new Configuration() .addClass(TestA.class) .addClass(TestB.class); SessionFactory factory = cfg.buildSessionFactory(); Session session4 = factory.openSession().getSession(EntityMode.DOM4J); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("testa"); Query query = session4.createQuery("from TestA as a"); for (Iterator it = query.iterate(); it.hasNext();) { Element e = (Element) it.next(); root.add(e); //TestA t = (TestA) it.next(); //System.out.println(t.getA_id()+t.getB().toString()); } } } Exception in thread "main" java.lang.ClassCastException: org.dom4j.tree.DefaultElement at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:279) at org.hibernate.pretty.MessageHelper.infoString(MessageHelper.java:68) at org.hibernate.engine.EntityKey.toString(EntityKey.java:77) at java.lang.String.valueOf(String.java:2577) at java.lang.StringBuffer.append(StringBuffer.java:220) at org.hibernate.util.StringHelper.toString(StringHelper.java:168) at org.hibernate.loader.Loader.getRow(Loader.java:762) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:295) at org.hibernate.loader.Loader.doQuery(Loader.java:389) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208) at org.hibernate.loader.Loader.loadCollection(Loader.java:1367) at org.hibernate.loader.collection.OneToManyLoader.initialize(OneToManyLoader.java:107) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1356) at org.hibernate.type.CollectionType.getCollection(CollectionType.java:470) at org.hibernate.type.CollectionType.resolveKey(CollectionType.java:328) at org.hibernate.type.CollectionType.resolve(CollectionType.java:322) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:494) at org.hibernate.loader.Loader.doQuery(Loader.java:413) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208) at org.hibernate.loader.Loader.loadEntity(Loader.java:1278) at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:141) at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:126) at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2491) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:386) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:367) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:166) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:119) at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:593) at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80) at org.hibernate.proxy.Dom4jLazyInitializer.getElement(Dom4jLazyInitializer.java:21) at org.hibernate.proxy.Dom4jProxy.target(Dom4jProxy.java:561) at org.hibernate.proxy.Dom4jProxy.getParent(Dom4jProxy.java:177) at org.dom4j.tree.AbstractElement.addNode(AbstractElement.java:2130) at org.dom4j.tree.AbstractElement.add(AbstractElement.java:1412) at Main.main(Main.java:27) Fetching data with default EntityMode (now commented out in class Main) works fine. (Tried also with H3 from CVS. Posted to forum, but no response in a week, so suppose to be a bug.)
    via by Martin Caslavsky,
  • Hibernate composite-id bag / Java / Sql.ru
    via by Unknown author,
  • When loging is set the INFO I get the following exception: javax.ejb.EJBException: java.lang.ClassCastException: java.lang.Long at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:219) at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107) at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:580) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:450) at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:290) at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:344) at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:202) Caused by: java.lang.ClassCastException: java.lang.Long at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:329) at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:187) at org.hibernate.event.def.ReattachVisitor.removeCollection(ReattachVisitor.java:60) at org.hibernate.event.def.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:46) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61) at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55) at org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:123) at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:72) at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:790) at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:768) at org.hibernate.ejb.AbstractEntityManagerImpl.remove(AbstractEntityManagerImpl.java:155) at org.jboss.ejb3.entity.InjectedEntityManager.remove(InjectedEntityManager.java:151) at com.teleglobal.modules.authentic.services.AuthenticAccountServiceBean.remove(AuthenticAccountServiceBean.java:99) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109) at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:219) at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107) at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:580) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:450) at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:290) at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:344) at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:202) at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:163) at org.jboss.remoting.Client.invoke(Client.java:258) at org.jboss.remoting.Client.invoke(Client.java:221) at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102) at $Proxy1.remove(Unknown Source) at com.teleglobal.modules.authentic.servcies.AuthenticAccountServiceTest.tearDown(AuthenticAccountServiceTest.java:23) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) The problem goes away when I turn logging down to WARN. I noticed that there was a similar bug (HHH-248) which was fixed in version 3.0.2 This exception really only occured when I used ManyToOne relationship using the referencedColumnName attribute and only when I tried to remove AuthenticAccount . My entities follow: @Entity @Table(name="ACCOUNT") @SequenceGenerator(name="ACCOUNT_SEQUENCE", sequenceName="ACCOUNT_SEQUENCE") public class AuthenticAccount implements Serializable { @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="ACCOUNT_SEQUENCE") @Column(name="ACN_ID") private long id; @Column(name="ACN_ACCOUNT_NUMBER", unique=true) private String accountNumber; // Default values for all authentic test accounts @Column(name="ACN_BALANCE_1") private long balance1 = 5000; @Column(name="ACN_STATUS") private String status = "O"; @Column(name="ACN_PRO_ID") private String proId = "11014"; @Column(name="ACN_CUR_ID") private long curId = 826; @Column(name="ACN_AMT_ID_1") private long amountId1 = 2; @Column(name="ACN_AMT_ID_2") private long amountId2 = 1; @Column(name="ACN_BALANCE_2") private long balance2 = 0; @Column(name="ACN_LAST_BATCH_UPDATE_DATE") private Date lastBatchUpdateDate; @Column(name="ACN_LAST_FEP_HOST_TRACE_NBR") private long lastFepHostTraceNumber = 0; @Column(name="ACN_LAST_HOST_FEP_TRACE_NBR") private long lastHostFepTraceNumber = 118; @Column(name="ACN_BILL_PAYMENT_FLG") private int billPaymentFlag = 1; @Column(name="ACN_TRANSFER_FLG") private int transferFlag = 0; @Column(name="ACN_FUNCTIONS") private int functions = 1; @Column(name="ACN_FEP_HOST_SUM") private long fepHostSum = 110; @Column(name="ACN_HOST_FEP_SUM") private long hostFepSum = 811233; @OneToOne(mappedBy="account", cascade=CascadeType.ALL, fetch=FetchType.EAGER) private Card card; @OneToMany(mappedBy="account", cascade=CascadeType.ALL, fetch=FetchType.EAGER) @JoinColumn(name="AMS_ACCOUNT_NUM", referencedColumnName="ACN_ACCOUNT_NUMBER", nullable = false, unique = true) private List<AuthenticAccountMiniStatement> miniStatements; public AuthenticAccount() { lastBatchUpdateDate = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a") .parse("09/06/2005 12:00:00 AM", new ParsePosition(0)); card = new Card(); miniStatements = new ArrayList<AuthenticAccountMiniStatement>(); } public String getAccountNumber() { return accountNumber; } public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public long getAmountId1() { return amountId1; } public void setAmountId1(long amountId1) { this.amountId1 = amountId1; } public long getAmountId2() { return amountId2; } public void setAmountId2(long amountId2) { this.amountId2 = amountId2; } public long getBalance1() { return balance1; } public void setBalance1(long balance1) { this.balance1 = balance1; } public long getBalance2() { return balance2; } public void setBalance2(long balance2) { this.balance2 = balance2; } public int getBillPaymentFlag() { return billPaymentFlag; } public void setBillPaymentFlag(int billPaymentFlag) { this.billPaymentFlag = billPaymentFlag; } public long getCurId() { return curId; } public void setCurId(long curId) { this.curId = curId; } public long getFepHostSum() { return fepHostSum; } public void setFepHostSum(long fepHostSum) { this.fepHostSum = fepHostSum; } public int getFunctions() { return functions; } public void setFunctions(int functions) { this.functions = functions; } public long getHostFepSum() { return hostFepSum; } public void setHostFepSum(long hostFepSum) { this.hostFepSum = hostFepSum; } public long getId() { return id; } public void setId(long id) { this.id = id; } public Date getLastBatchUpdateDate() { return lastBatchUpdateDate; } public void setLastBatchUpdateDate(Date lastBatchUpdateDate) { this.lastBatchUpdateDate = lastBatchUpdateDate; } public long getLastFepHostTraceNumber() { return lastFepHostTraceNumber; } public void setLastFepHostTraceNumber(long lastFepHostTraceNumber) { this.lastFepHostTraceNumber = lastFepHostTraceNumber; } public long getLastHostFepTraceNumber() { return lastHostFepTraceNumber; } public void setLastHostFepTraceNumber(long lastHostFepTraceNumber) { this.lastHostFepTraceNumber = lastHostFepTraceNumber; } public String getProId() { return proId; } public void setProId(String proId) { this.proId = proId; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public int getTransferFlag() { return transferFlag; } public void setTransferFlag(int transferFlag) { this.transferFlag = transferFlag; } public Card getCard() { return card; } public void setCard(Card card) { this.card = card; } public void addMiniStatement(AuthenticAccountMiniStatement miniStatement) { miniStatement.setAccount(this); this.miniStatements.add(miniStatement); } public void removeMiniStatement(AuthenticAccountMiniStatement miniStatement) { this.miniStatements.remove(miniStatement); } public List<AuthenticAccountMiniStatement> getMiniStatements() { return miniStatements; } public void setMiniStatements(List<AuthenticAccountMiniStatement> miniStatements) { this.miniStatements = miniStatements; } } @Entity @Table(name = "ACCOUNT_MINI_STATEMENT") @SequenceGenerator(name="MINI_STATEMENT_SEQUENCE", sequenceName="MINI_STATEMENT_SEQUENCE") public class AuthenticAccountMiniStatement implements Serializable { @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MINI_STATEMENT_SEQUENCE") @Column(name="AMS_TXN_SEQ") private long id; @Column(name="AMS_TXN_CODE") private String transactionDescription = "LOAD"; @Column(name="AMS_TXN_DATE") private Date transactionDate = new Date(); @Column(name="AMS_TXN_AMOUNT") private long transactionAmount = 10; @Column(name="AMS_TRL_BUSINESS_DATE") private Date transactionLogBusinessDate = new Date(); @Column(name="AMS_TRL_ID") private long transactionLogId = 34610; @Column(name="AMS_GRP_SEQ") private long groupSequence = 1; @ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="AMS_ACCOUNT_NUM", referencedColumnName="ACN_ACCOUNT_NUMBER", nullable = false, unique = true) private AuthenticAccount account; public AuthenticAccountMiniStatement() { } public long getTransactionAmount() { return transactionAmount; } public void setTransactionAmount(long transactionAmount) { this.transactionAmount = transactionAmount; } public Date getTransactionDate() { return transactionDate; } public void setTransactionDate(Date transactionDate) { this.transactionDate = transactionDate; } public String getTransactionDescription() { return transactionDescription; } public void setTransactionDescription(String transactionDescription) { this.transactionDescription = transactionDescription; } public long getGroupSequence() { return groupSequence; } public void setGroupSequence(long groupSequence) { this.groupSequence = groupSequence; } public long getId() { return id; } public void setId(long id) { this.id = id; } public Date getTransactionLogBusinessDate() { return transactionLogBusinessDate; } public void setTransactionLogBusinessDate(Date transactionLogBusinessDate) { this.transactionLogBusinessDate = transactionLogBusinessDate; } public long getTransactionLogId() { return transactionLogId; } public void setTransactionLogId(long transactionLogId) { this.transactionLogId = transactionLogId; } public AuthenticAccount getAccount() { return account; } public void setAccount(AuthenticAccount account) { this.account = account; } } @Entity @Table(name="CARD") @SequenceGenerator(name="CARD_SEQUENCE", sequenceName="CARD_SEQUENCE") public class Card implements Serializable { @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="CARD_SEQUENCE") @Column(name="CRD_ID") private long id; @Column(name="CRD_PAN") private String primaryAccountNumber; @Column(name="CRD_STATUS_1") private String status1 = "A"; @Column(name="CRD_CURRENT_PVV") private long currentPvv = 0; @Column(name="CRD_PIN_RETRY_COUNT") private long pinRetryCount = 0; @Column(name="CRD_CUSTOM_INDEX_1") private String customIndex1 = "GC"; // Default values for all authentic test cards @Column(name="CRD_CARD_SEQUENCE_NBR") private long cardSequenceNumber = 0; @Column(name="CRD_CPD_ID") private long cpdId = 250; @Column(name="CRD_LAST_SOURCE") private String lastSource = "U"; @Column(name="CRD_FUNCTIONS") private int functions = 1; @Column(name="CRD_CURRENT_PIN_OFFSET") private String currentPinOffset = "0"; @Column(name="CRD_ISSUE_DATE_1") private Date issueDate1; @Column(name="CRD_EXPIRY_DATE_1") private Date expiryDate1; @Column(name="CRD_EXPIRY_DATE_2") private Date expiryDate2; @Column(name="CRD_STATUS_1_DATE") private Date status1Date; @ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="CRD_PRIMARY_ACN_ID", nullable=false, unique=true) private AuthenticAccount account; public Card() { this.issueDate1 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a").parse("09/06/2005 12:00:00 AM", new ParsePosition(0)); this.expiryDate1 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a").parse("01/06/2015 12:00:00 AM", new ParsePosition(0)); this.expiryDate2 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a").parse("01/06/2015 12:00:00 AM", new ParsePosition(0)); this.status1Date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a").parse("09/06/2005 12:00:00 AM", new ParsePosition(0)); } public String getPrimaryAccountNumber() { return primaryAccountNumber; } public void setPrimaryAccountNumber(String primaryAccountNumber) { this.primaryAccountNumber = primaryAccountNumber; } public long getCpdId() { return cpdId; } public void setCpdId(long cpdId) { this.cpdId = cpdId; } public String getCurrentPinOffset() { return currentPinOffset; } public void setCurrentPinOffset(String currentPinOffset) { this.currentPinOffset = currentPinOffset; } public long getCurrentPvv() { return currentPvv; } public void setCurrentPvv(long currentPvv) { this.currentPvv = currentPvv; } public String getCustomIndex1() { return customIndex1; } public void setCustomIndex1(String customIndex1) { this.customIndex1 = customIndex1; } public Date getExpiryDate1() { return expiryDate1; } public void setExpiryDate1(Date expiryDate1) { this.expiryDate1 = expiryDate1; } public Date getExpiryDate2() { return expiryDate2; } public void setExpiryDate2(Date expiryDate2) { this.expiryDate2 = expiryDate2; } public int getFunctions() { return functions; } public void setFunctions(int functions) { this.functions = functions; } public long getId() { return id; } public void setId(long id) { this.id = id; } public Date getIssueDate1() { return issueDate1; } public void setIssueDate1(Date issueDate1) { this.issueDate1 = issueDate1; } public String getLastSource() { return lastSource; } public void setLastSource(String lastSource) { this.lastSource = lastSource; } public long getPinRetryCount() { return pinRetryCount; } public void setPinRetryCount(long pinRetryCount) { this.pinRetryCount = pinRetryCount; } public long getCardSequenceNumber() { return cardSequenceNumber; } public void setCardSequenceNumber(long cardSequenceNumber) { this.cardSequenceNumber = cardSequenceNumber; } public String getStatus1() { return status1; } public void setStatus1(String status1) { this.status1 = status1; } public Date getStatus1Date() { return status1Date; } public void setStatus1Date(Date status1Date) { this.status1Date = status1Date; } public AuthenticAccount getAccount() { return account; } public void setAccount(AuthenticAccount account) { this.account = account; } } Further more, when I try to remove an AUthentic entity (with logging set to WARN), I find that the AuthenticMiniStatements are not removed. This probably should be raised as another bug.
    via by Steven Verze,
  • The method toLoggableString in ComponentType is used to provide tracing output when running with log level DEBUG. In some circumstances it throws a ClassCastException. This is not a good idea in tracing code and obscures underlying problems. In my case the underlying problem was a previous incorrect call to set a parameter value in a query. I saw that previous JIRA issues have mentioned this ClassCastException as a side effect of other underlying problems - it is a distraction and time-waster. Lines 375-378 read: EntityMode entityMode = tuplizerMapping.guessEntityMode( value ); if ( entityMode == null ) { throw new ClassCastException( value.getClass().getName() ); } A better solution would be to just us String.valueOf EntityMode entityMode = tuplizerMapping.guessEntityMode( value ); if ( entityMode == null ) { return String.valueOf(value); } Another possibility would be to concatenate some diagnostic message with String.valueOf, but personally I don't think that be helpful. Stack trace is: Exception in thread "main" java.lang.ClassCastException: java.lang.String at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:377) at org.hibernate.pretty.Printer.toString(Printer.java:76) at org.hibernate.engine.QueryParameters.traceParameters(QueryParameters.java:277) at org.hibernate.engine.query.HQLQueryPlan.performIterate(HQLQueryPlan.java:210) at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1192) at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:46) at hib.example.EntityWithEmbeddable.main(EntityWithEmbeddable.java:44) Example code for the classes and schema to reproduce is pasted into the attachment.
    via by Pete Geraghty,
  • The method toLoggableString in ComponentType is used to provide tracing output when running with log level DEBUG. In some circumstances it throws a ClassCastException. This is not a good idea in tracing code and obscures underlying problems. In my case the underlying problem was a previous incorrect call to set a parameter value in a query. I saw that previous JIRA issues have mentioned this ClassCastException as a side effect of other underlying problems - it is a distraction and time-waster. Lines 375-378 read: EntityMode entityMode = tuplizerMapping.guessEntityMode( value ); if ( entityMode == null ) { throw new ClassCastException( value.getClass().getName() ); } A better solution would be to just us String.valueOf EntityMode entityMode = tuplizerMapping.guessEntityMode( value ); if ( entityMode == null ) { return String.valueOf(value); } Another possibility would be to concatenate some diagnostic message with String.valueOf, but personally I don't think that be helpful. Stack trace is: Exception in thread "main" java.lang.ClassCastException: java.lang.String at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:377) at org.hibernate.pretty.Printer.toString(Printer.java:76) at org.hibernate.engine.QueryParameters.traceParameters(QueryParameters.java:277) at org.hibernate.engine.query.HQLQueryPlan.performIterate(HQLQueryPlan.java:210) at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1192) at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:46) at hib.example.EntityWithEmbeddable.main(EntityWithEmbeddable.java:44) Example code for the classes and schema to reproduce is pasted into the attachment.
    via by Pete Geraghty,
  • When loging is set the INFO I get the following exception: javax.ejb.EJBException: java.lang.ClassCastException: java.lang.Long at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:219) at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107) at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:580) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:450) at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:290) at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:344) at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:202) Caused by: java.lang.ClassCastException: java.lang.Long at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:329) at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:187) at org.hibernate.event.def.ReattachVisitor.removeCollection(ReattachVisitor.java:60) at org.hibernate.event.def.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:46) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61) at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55) at org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:123) at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:72) at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:790) at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:768) at org.hibernate.ejb.AbstractEntityManagerImpl.remove(AbstractEntityManagerImpl.java:155) at org.jboss.ejb3.entity.InjectedEntityManager.remove(InjectedEntityManager.java:151) at com.teleglobal.modules.authentic.services.AuthenticAccountServiceBean.remove(AuthenticAccountServiceBean.java:99) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109) at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:219) at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107) at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:580) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:450) at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:290) at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:344) at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:202) at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:163) at org.jboss.remoting.Client.invoke(Client.java:258) at org.jboss.remoting.Client.invoke(Client.java:221) at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102) at $Proxy1.remove(Unknown Source) at com.teleglobal.modules.authentic.servcies.AuthenticAccountServiceTest.tearDown(AuthenticAccountServiceTest.java:23) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) The problem goes away when I turn logging down to WARN. I noticed that there was a similar bug (HHH-248) which was fixed in version 3.0.2 This exception really only occured when I used ManyToOne relationship using the referencedColumnName attribute and only when I tried to remove AuthenticAccount . My entities follow: @Entity @Table(name="ACCOUNT") @SequenceGenerator(name="ACCOUNT_SEQUENCE", sequenceName="ACCOUNT_SEQUENCE") public class AuthenticAccount implements Serializable { @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="ACCOUNT_SEQUENCE") @Column(name="ACN_ID") private long id; @Column(name="ACN_ACCOUNT_NUMBER", unique=true) private String accountNumber; // Default values for all authentic test accounts @Column(name="ACN_BALANCE_1") private long balance1 = 5000; @Column(name="ACN_STATUS") private String status = "O"; @Column(name="ACN_PRO_ID") private String proId = "11014"; @Column(name="ACN_CUR_ID") private long curId = 826; @Column(name="ACN_AMT_ID_1") private long amountId1 = 2; @Column(name="ACN_AMT_ID_2") private long amountId2 = 1; @Column(name="ACN_BALANCE_2") private long balance2 = 0; @Column(name="ACN_LAST_BATCH_UPDATE_DATE") private Date lastBatchUpdateDate; @Column(name="ACN_LAST_FEP_HOST_TRACE_NBR") private long lastFepHostTraceNumber = 0; @Column(name="ACN_LAST_HOST_FEP_TRACE_NBR") private long lastHostFepTraceNumber = 118; @Column(name="ACN_BILL_PAYMENT_FLG") private int billPaymentFlag = 1; @Column(name="ACN_TRANSFER_FLG") private int transferFlag = 0; @Column(name="ACN_FUNCTIONS") private int functions = 1; @Column(name="ACN_FEP_HOST_SUM") private long fepHostSum = 110; @Column(name="ACN_HOST_FEP_SUM") private long hostFepSum = 811233; @OneToOne(mappedBy="account", cascade=CascadeType.ALL, fetch=FetchType.EAGER) private Card card; @OneToMany(mappedBy="account", cascade=CascadeType.ALL, fetch=FetchType.EAGER) @JoinColumn(name="AMS_ACCOUNT_NUM", referencedColumnName="ACN_ACCOUNT_NUMBER", nullable = false, unique = true) private List<AuthenticAccountMiniStatement> miniStatements; public AuthenticAccount() { lastBatchUpdateDate = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a") .parse("09/06/2005 12:00:00 AM", new ParsePosition(0)); card = new Card(); miniStatements = new ArrayList<AuthenticAccountMiniStatement>(); } public String getAccountNumber() { return accountNumber; } public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public long getAmountId1() { return amountId1; } public void setAmountId1(long amountId1) { this.amountId1 = amountId1; } public long getAmountId2() { return amountId2; } public void setAmountId2(long amountId2) { this.amountId2 = amountId2; } public long getBalance1() { return balance1; } public void setBalance1(long balance1) { this.balance1 = balance1; } public long getBalance2() { return balance2; } public void setBalance2(long balance2) { this.balance2 = balance2; } public int getBillPaymentFlag() { return billPaymentFlag; } public void setBillPaymentFlag(int billPaymentFlag) { this.billPaymentFlag = billPaymentFlag; } public long getCurId() { return curId; } public void setCurId(long curId) { this.curId = curId; } public long getFepHostSum() { return fepHostSum; } public void setFepHostSum(long fepHostSum) { this.fepHostSum = fepHostSum; } public int getFunctions() { return functions; } public void setFunctions(int functions) { this.functions = functions; } public long getHostFepSum() { return hostFepSum; } public void setHostFepSum(long hostFepSum) { this.hostFepSum = hostFepSum; } public long getId() { return id; } public void setId(long id) { this.id = id; } public Date getLastBatchUpdateDate() { return lastBatchUpdateDate; } public void setLastBatchUpdateDate(Date lastBatchUpdateDate) { this.lastBatchUpdateDate = lastBatchUpdateDate; } public long getLastFepHostTraceNumber() { return lastFepHostTraceNumber; } public void setLastFepHostTraceNumber(long lastFepHostTraceNumber) { this.lastFepHostTraceNumber = lastFepHostTraceNumber; } public long getLastHostFepTraceNumber() { return lastHostFepTraceNumber; } public void setLastHostFepTraceNumber(long lastHostFepTraceNumber) { this.lastHostFepTraceNumber = lastHostFepTraceNumber; } public String getProId() { return proId; } public void setProId(String proId) { this.proId = proId; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public int getTransferFlag() { return transferFlag; } public void setTransferFlag(int transferFlag) { this.transferFlag = transferFlag; } public Card getCard() { return card; } public void setCard(Card card) { this.card = card; } public void addMiniStatement(AuthenticAccountMiniStatement miniStatement) { miniStatement.setAccount(this); this.miniStatements.add(miniStatement); } public void removeMiniStatement(AuthenticAccountMiniStatement miniStatement) { this.miniStatements.remove(miniStatement); } public List<AuthenticAccountMiniStatement> getMiniStatements() { return miniStatements; } public void setMiniStatements(List<AuthenticAccountMiniStatement> miniStatements) { this.miniStatements = miniStatements; } } @Entity @Table(name = "ACCOUNT_MINI_STATEMENT") @SequenceGenerator(name="MINI_STATEMENT_SEQUENCE", sequenceName="MINI_STATEMENT_SEQUENCE") public class AuthenticAccountMiniStatement implements Serializable { @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MINI_STATEMENT_SEQUENCE") @Column(name="AMS_TXN_SEQ") private long id; @Column(name="AMS_TXN_CODE") private String transactionDescription = "LOAD"; @Column(name="AMS_TXN_DATE") private Date transactionDate = new Date(); @Column(name="AMS_TXN_AMOUNT") private long transactionAmount = 10; @Column(name="AMS_TRL_BUSINESS_DATE") private Date transactionLogBusinessDate = new Date(); @Column(name="AMS_TRL_ID") private long transactionLogId = 34610; @Column(name="AMS_GRP_SEQ") private long groupSequence = 1; @ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="AMS_ACCOUNT_NUM", referencedColumnName="ACN_ACCOUNT_NUMBER", nullable = false, unique = true) private AuthenticAccount account; public AuthenticAccountMiniStatement() { } public long getTransactionAmount() { return transactionAmount; } public void setTransactionAmount(long transactionAmount) { this.transactionAmount = transactionAmount; } public Date getTransactionDate() { return transactionDate; } public void setTransactionDate(Date transactionDate) { this.transactionDate = transactionDate; } public String getTransactionDescription() { return transactionDescription; } public void setTransactionDescription(String transactionDescription) { this.transactionDescription = transactionDescription; } public long getGroupSequence() { return groupSequence; } public void setGroupSequence(long groupSequence) { this.groupSequence = groupSequence; } public long getId() { return id; } public void setId(long id) { this.id = id; } public Date getTransactionLogBusinessDate() { return transactionLogBusinessDate; } public void setTransactionLogBusinessDate(Date transactionLogBusinessDate) { this.transactionLogBusinessDate = transactionLogBusinessDate; } public long getTransactionLogId() { return transactionLogId; } public void setTransactionLogId(long transactionLogId) { this.transactionLogId = transactionLogId; } public AuthenticAccount getAccount() { return account; } public void setAccount(AuthenticAccount account) { this.account = account; } } @Entity @Table(name="CARD") @SequenceGenerator(name="CARD_SEQUENCE", sequenceName="CARD_SEQUENCE") public class Card implements Serializable { @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="CARD_SEQUENCE") @Column(name="CRD_ID") private long id; @Column(name="CRD_PAN") private String primaryAccountNumber; @Column(name="CRD_STATUS_1") private String status1 = "A"; @Column(name="CRD_CURRENT_PVV") private long currentPvv = 0; @Column(name="CRD_PIN_RETRY_COUNT") private long pinRetryCount = 0; @Column(name="CRD_CUSTOM_INDEX_1") private String customIndex1 = "GC"; // Default values for all authentic test cards @Column(name="CRD_CARD_SEQUENCE_NBR") private long cardSequenceNumber = 0; @Column(name="CRD_CPD_ID") private long cpdId = 250; @Column(name="CRD_LAST_SOURCE") private String lastSource = "U"; @Column(name="CRD_FUNCTIONS") private int functions = 1; @Column(name="CRD_CURRENT_PIN_OFFSET") private String currentPinOffset = "0"; @Column(name="CRD_ISSUE_DATE_1") private Date issueDate1; @Column(name="CRD_EXPIRY_DATE_1") private Date expiryDate1; @Column(name="CRD_EXPIRY_DATE_2") private Date expiryDate2; @Column(name="CRD_STATUS_1_DATE") private Date status1Date; @ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="CRD_PRIMARY_ACN_ID", nullable=false, unique=true) private AuthenticAccount account; public Card() { this.issueDate1 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a").parse("09/06/2005 12:00:00 AM", new ParsePosition(0)); this.expiryDate1 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a").parse("01/06/2015 12:00:00 AM", new ParsePosition(0)); this.expiryDate2 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a").parse("01/06/2015 12:00:00 AM", new ParsePosition(0)); this.status1Date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a").parse("09/06/2005 12:00:00 AM", new ParsePosition(0)); } public String getPrimaryAccountNumber() { return primaryAccountNumber; } public void setPrimaryAccountNumber(String primaryAccountNumber) { this.primaryAccountNumber = primaryAccountNumber; } public long getCpdId() { return cpdId; } public void setCpdId(long cpdId) { this.cpdId = cpdId; } public String getCurrentPinOffset() { return currentPinOffset; } public void setCurrentPinOffset(String currentPinOffset) { this.currentPinOffset = currentPinOffset; } public long getCurrentPvv() { return currentPvv; } public void setCurrentPvv(long currentPvv) { this.currentPvv = currentPvv; } public String getCustomIndex1() { return customIndex1; } public void setCustomIndex1(String customIndex1) { this.customIndex1 = customIndex1; } public Date getExpiryDate1() { return expiryDate1; } public void setExpiryDate1(Date expiryDate1) { this.expiryDate1 = expiryDate1; } public Date getExpiryDate2() { return expiryDate2; } public void setExpiryDate2(Date expiryDate2) { this.expiryDate2 = expiryDate2; } public int getFunctions() { return functions; } public void setFunctions(int functions) { this.functions = functions; } public long getId() { return id; } public void setId(long id) { this.id = id; } public Date getIssueDate1() { return issueDate1; } public void setIssueDate1(Date issueDate1) { this.issueDate1 = issueDate1; } public String getLastSource() { return lastSource; } public void setLastSource(String lastSource) { this.lastSource = lastSource; } public long getPinRetryCount() { return pinRetryCount; } public void setPinRetryCount(long pinRetryCount) { this.pinRetryCount = pinRetryCount; } public long getCardSequenceNumber() { return cardSequenceNumber; } public void setCardSequenceNumber(long cardSequenceNumber) { this.cardSequenceNumber = cardSequenceNumber; } public String getStatus1() { return status1; } public void setStatus1(String status1) { this.status1 = status1; } public Date getStatus1Date() { return status1Date; } public void setStatus1Date(Date status1Date) { this.status1Date = status1Date; } public AuthenticAccount getAccount() { return account; } public void setAccount(AuthenticAccount account) { this.account = account; } } Further more, when I try to remove an AUthentic entity (with logging set to WARN), I find that the AuthenticMiniStatements are not removed. This probably should be raised as another bug.
    via by Steven Verze,
    • java.lang.ClassCastException: org.dom4j.tree.DefaultElement at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:279) at org.hibernate.pretty.MessageHelper.infoString(MessageHelper.java:68) at org.hibernate.engine.EntityKey.toString(EntityKey.java:77) at java.lang.String.valueOf(String.java:2577) at java.lang.StringBuffer.append(StringBuffer.java:220) at org.hibernate.util.StringHelper.toString(StringHelper.java:168) at org.hibernate.loader.Loader.getRow(Loader.java:762) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:295) at org.hibernate.loader.Loader.doQuery(Loader.java:389) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208) at org.hibernate.loader.Loader.loadCollection(Loader.java:1367) at org.hibernate.loader.collection.OneToManyLoader.initialize(OneToManyLoader.java:107) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1356) at org.hibernate.type.CollectionType.getCollection(CollectionType.java:470) at org.hibernate.type.CollectionType.resolveKey(CollectionType.java:328) at org.hibernate.type.CollectionType.resolve(CollectionType.java:322) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:494) at org.hibernate.loader.Loader.doQuery(Loader.java:413) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208) at org.hibernate.loader.Loader.loadEntity(Loader.java:1278) at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:141) at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:126) at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2491) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:386) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:367) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:166) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:119) at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:593) at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80) at org.hibernate.proxy.Dom4jLazyInitializer.getElement(Dom4jLazyInitializer.java:21) at org.hibernate.proxy.Dom4jProxy.target(Dom4jProxy.java:561) at org.hibernate.proxy.Dom4jProxy.getParent(Dom4jProxy.java:177) at org.dom4j.tree.AbstractElement.addNode(AbstractElement.java:2130) at org.dom4j.tree.AbstractElement.add(AbstractElement.java:1412) at Main.main(Main.java:27)
    No Bugmate found.