I want to modify the ModuleProperty collection of the Module class and then
merge it back. When I use the
| public Module updateModule(Module module){
| em.merge(module) ;
| return module;
| }
|
in my stateless session bean, it throws exception (attached at the bottom of
the post). When I individually persist or merge each ModuleProperty in the
collection, it works, however I am getting "failed batch" exception when I try
to remove a ModuleProperty using em.remove(property) and also removing from
module module.getProperties().remove(property) then call merge on the module.
Am I doing something wrong?
I have the following two classes:
| @Entity
| @Table(name="Module")
| public class Module implements Serializable{
|
| @Id
| @GeneratedValue
| int moduleID;
|
| @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
| @JoinColumn(name="MODULE_ID")
| Collection<ModuleProperty> properties = new HashSet<ModuleProperty>();
|
| public int getModuleID() {
| return moduleID;
| }
| public void setModuleID(int moduleID) {
| this.moduleID = moduleID;
| }
|
| public Collection<ModuleProperty> getProperties() {
| return properties;
| }
| public void setProperties(Collection<ModuleProperty> properties) {
| this.properties = properties;
| }
| }
|
| @Entity
| @Table(name="ModuleProperty")
| public class ModuleProperty implements Serializable {
| /**
| *
| */
| private static final long serialVersionUID = 1L;
| @EmbeddedId
| @AttributeOverrides({
| @AttributeOverride(name="moduleID", [EMAIL
PROTECTED](name="MODULE_ID")),
| @AttributeOverride(name="name", [EMAIL PROTECTED](name="NAME"))
| })
| ModulePropertyPK id;
| String value;
| public ModulePropertyPK getId() {
| return id;
| }
| public void setId(ModulePropertyPK id) {
| this.id = id;
| }
| public String getValue() {
| return value;
| }
| public void setValue(String value) {
| this.value = value;
| }
| }
|
| @Embeddable
| public class ModulePropertyPK implements Serializable{
| int moduleID;
| String name;
| public String getName() {
| return name;
| }
| public void setName(String name) {
| this.name = name;
| }
|
| @ManyToOne
| @JoinColumn(name="MODULE_ID",nullable=false)
| public int getModuleID() {
| return moduleID;
| }
| public void setModuleID(int moduleID) {
| this.moduleID = moduleID;
| }
|
| @Override
| public int hashCode() {
| String tmp = name +moduleID;
| return tmp.hashCode();
| }
|
| @Override
| public boolean equals(Object obj) {
| if(obj instanceof ModulePropertyPK){
| ModulePropertyPK pk = (ModulePropertyPK)obj;
| return (pk.moduleID == this.moduleID && this.name !=
null && name.equals(pk.name));
| }
| return false;
| }
| }
|
|
4:54:01,718 ERROR [JDBCExceptionReporter] failed batch
14:54:01,718 ERROR [AbstractFlushingEventListener] Could not synchronize
database state with session
org.hibernate.exception.GenericJDBCException: could not insert:
[org.vss.ejb3.eb.ModuleProperty]
at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2140)
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2503)
at
org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:988)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:337)
at
org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:473)
at
org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1488)
at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1107)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:321)
at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
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.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:167)
at
org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:100)
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:225)
at
org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:55)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at
org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
at $Proxy155.updateElement(Unknown Source)
at
org.vss.mbean.CORViewService.getHMSElementsAlarm(CORViewService.java:568)
at org.vss.mbean.CORViewService.scanHMSElement(CORViewService.java:389)
at org.vss.mbean.CORViewService.scanElement(CORViewService.java:283)
at
org.vss.mbean.CORViewService$PollingThread.run(CORViewService.java:231)
Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
at
org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeBatch(CachedPreparedStatement.java:478)
at
org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:517)
at
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at
org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:34)
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2120)
... 39 more
14:54:01,718 ERROR [STDERR] java.lang.RuntimeException:
org.jboss.tm.JBossRollbackException: Unable to commit,
tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=OPT0051/3210, BranchQual=,
localId=3210] status=STATUS_NO_TRANSACTION; - nested throwable:
(javax.persistence.PersistenceException:
org.hibernate.exception.GenericJDBCException: could not insert:
[org.vss.ejb3.eb.ModuleProperty])
14:54:01,718 ERROR [STDERR] at
org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:198)
14:54:01,718 ERROR [STDERR] at
org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:180)
14:54:01,718 ERROR [STDERR] at
org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
14:54:01,718 ERROR [STDERR] at
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192)
14:54:01,718 ERROR [STDERR] at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
14:54:01,718 ERROR [STDERR] at
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
14:54:01,718 ERROR [STDERR] at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
14:54:01,718 ERROR [STDERR] at
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
14:54:01,718 ERROR [STDERR] at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
14:54:01,718 ERROR [STDERR] at
org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:167)
14:54:01,718 ERROR [STDERR] at
org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:100)
14:54:01,718 ERROR [STDERR] at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
14:54:01,718 ERROR [STDERR] at
org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
14:54:01,718 ERROR [STDERR] at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
14:54:01,718 ERROR [STDERR] at
org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
14:54:01,718 ERROR [STDERR] at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
14:54:01,718 ERROR [STDERR] at
org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
14:54:01,718 ERROR [STDERR] at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
14:54:01,718 ERROR [STDERR] at
org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:225)
14:54:01,718 ERROR [STDERR] at
org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:55)
14:54:01,718 ERROR [STDERR] at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
14:54:01,718 ERROR [STDERR] at
org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
14:54:01,718 ERROR [STDERR] at $Proxy155.updateElement(Unknown Source)
14:54:01,718 ERROR [STDERR] at
org.vss.mbean.CORViewService.getHMSElementsAlarm(CORViewService.java:568)
14:54:01,718 ERROR [STDERR] at
org.vss.mbean.CORViewService.scanHMSElement(CORViewService.java:389)
14:54:01,718 ERROR [STDERR] at
org.vss.mbean.CORViewService.scanElement(CORViewService.java:283)
14:54:01,718 ERROR [STDERR] at
org.vss.mbean.CORViewService$PollingThread.run(CORViewService.java:231)
14:54:01,718 ERROR [STDERR] Caused by: org.jboss.tm.JBossRollbackException:
Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257,
GlobalId=OPT0051/3210, BranchQual=, localId=3210] status=STATUS_NO_TRANSACTION;
- nested throwable: (javax.persistence.PersistenceException:
org.hibernate.exception.GenericJDBCException: could not insert:
[org.vss.ejb3.eb.ModuleProperty])
14:54:01,718 ERROR [STDERR] at
org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:369)
14:54:01,734 ERROR [STDERR] at
org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
14:54:01,734 ERROR [STDERR] ... 25 more
14:54:01,734 ERROR [STDERR] Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.GenericJDBCException: could not insert:
[org.vss.ejb3.eb.ModuleProperty]
14:54:01,734 ERROR [STDERR] at
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:562)
14:54:01,734 ERROR [STDERR] at
org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:482)
14:54:01,734 ERROR [STDERR] at
org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1488)
14:54:01,734 ERROR [STDERR] at
org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1107)
14:54:01,734 ERROR [STDERR] at
org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:321)
14:54:01,734 ERROR [STDERR] ... 26 more
14:54:01,734 ERROR [STDERR] Caused by:
org.hibernate.exception.GenericJDBCException: could not insert:
[org.vss.ejb3.eb.ModuleProperty]
14:54:01,734 ERROR [STDERR] at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
14:54:01,734 ERROR [STDERR] at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
14:54:01,734 ERROR [STDERR] at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
14:54:01,734 ERROR [STDERR] at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2140)
14:54:01,734 ERROR [STDERR] at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2503)
14:54:01,734 ERROR [STDERR] at
org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
14:54:01,734 ERROR [STDERR] at
org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
14:54:01,734 ERROR [STDERR] at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
14:54:01,734 ERROR [STDERR] at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
14:54:01,734 ERROR [STDERR] at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
14:54:01,734 ERROR [STDERR] at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
14:54:01,734 ERROR [STDERR] at
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:988)
14:54:01,734 ERROR [STDERR] at
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:337)
14:54:01,734 ERROR [STDERR] at
org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:473)
14:54:01,734 ERROR [STDERR] ... 29 more
14:54:01,734 ERROR [STDERR] Caused by: java.sql.BatchUpdateException: failed
batch
14:54:01,734 ERROR [STDERR] at
org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
14:54:01,734 ERROR [STDERR] at
org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
14:54:01,734 ERROR [STDERR] at
org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeBatch(CachedPreparedStatement.java:478)
14:54:01,734 ERROR [STDERR] at
org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:517)
14:54:01,734 ERROR [STDERR] at
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
14:54:01,734 ERROR [STDERR] at
org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:34)
14:54:01,734 ERROR [STDERR] at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2120)
14:54:01,734 ERROR [STDERR] ... 39 more
14:54:01,734 INFO [CORViewService] Waiting for element polling queue...
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3945822#3945822
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3945822
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user