[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] Issues with remove jta, eclipselink with a relational object..
|
Greetings,
I am having issues with delete on a table which connects two entities
but otherwise is independant(No cascade,etc). I keep getting
Caused by: java.lang.IllegalArgumentException: Entity must be managed
to call remove: UserRole@595, try merging the detached and try the
remove again.
Following is my model.I have a class UserRole which is defined as follows
@Entity
@Table(name="USER_ROLE",
uniqueConstraints={@UniqueConstraint(columnNames={"USER_ID",
"ROLE_ID"})})
public class UserRole extends PersistableObject implements
Effectivity<EffectivePeriodWithEnable>
{
@OneToOne(fetch=FetchType.EAGER)
@JoinColumn(name="USER_ID", nullable=false)
private User user ;
@OneToOne(fetch=FetchType.EAGER)
@JoinColumn(name="ROLE_ID", nullable=false)
private Role role ;
@Column(name="DEFAULT_ROLE", nullable=false)
private Boolean defaultRole ;
@Embedded
private EffectivePeriodWithEnable span ;
}
which basically is a relation between User and Role with some
attributes defined in the relation like the defaultRole and a span
when the relation would be active/inactive.
User is like this
public class User extends PersistableObject
{
@Column(name="LOGIN", nullable=false, unique=true, length=20)
private String loginName;
@Column(name="FIRST_NM", nullable=false, length=35)
private String firstName;
@Column(name="MID_NM", nullable=true, length=25)
private String middleName;
...etc...etc(Not relevant to this discussion)
}
@Entity
@Table(name="ROLE")
public class Role extends PersistableObject
{
@Column(name="NAME", nullable=false, unique=true, length=50)
private String name;
@Column(name="DESCRIPTION", nullable=true, length=255)
private String description;
....etc...etc(Not relevant to this discussion)
}
I have a method defined in the DAO something like this
public void setRoles(User user, List<Role> roles,
EffectivePeriodWithEnable p) throws DAOException
{
try
{
ExpressionBuilder eb = new ExpressionBuilder(UserRole.class) ;
Expression exp = eb.get("user").equal(user) ;
List<UserRole> uroles = (List<UserRole>)
getObjects(UserRole.class, exp);
EntityManager entityManager = getEntityManager() ;
if (uroles != null)
{
for (UserRole urole: uroles)
{
// I have tried this with and without merge . I
dont think that i should do a merge since the getobjects (which
internally uses ReadAllQuery to fetch
// the object is just got here in this method..
getEntityManager().remove(getEntityManager().merge(urole));
}
}
}
}
I am running in a jta container and these methods are called within an
ejb method call . When it runs and tries to remove , following is what
i get
Caused by: java.lang.IllegalArgumentException: Entity must be managed
to call remove: com.abc.hps.vvv.security.bom.helpers.UserRole@595, try
merging the detached and try the remove again.
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.performRemove(UnitOfWorkImpl.java:3559)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.remove(EntityManagerImpl.java:518)
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:597)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
at $Proxy640.remove(Unknown Source)
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:597)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at $Proxy640.remove(Unknown Source)
at com.abc.hps.vvv.common.dao.eclipselink.EclipseLinkDAO.deleteObject(EclipseLinkDAO.java:179)
at com.abc.hps.vvv.dao.eclipselink.EclipseLinkSecurityDAO.setRoles(EclipseLinkSecurityDAO.java:212)
at com.abc.hps.vvv.security.impls.vvvSecurityImpl.setRoles(vvvSecurityImpl.java:401)
at com.abc.hps.vvv.security.impls.vvvSecurityImpl.setRoles(vvvSecurityImpl.java:412)
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:597)
at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
at sun.reflect.GeneratedMethodAccessor369.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_1937287906.invoke(InvocationContextInterceptor_z_fillMethod_1937287906.java)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_1937287906.invoke(InvocationContextInterceptor_z_setup_1937287906.java)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
... 96 more
12:51:28,665 INFO [STDOUT]:152 12:51:28,664 TRACE
[ClassPathXmlApplicationContext]:301 Publishing event in
ApplicationContext 'vvvWebBeanFactory':
org.springframework.security.access.event.PublicInvocationEvent[source=FilterInvocation:
URL: /abcrw/js/abc/assets/set2/delete_16.png]
We are using eclipselink 2.4.0 and are running in a jboss 5.1.0.GA
container. Please help !!! I just dont understand why it is not able
to remove .. May be i am missing something
Cheers
Vaidya