[Persistence, JBoss/CMP, Hibernate, Database] - Problem cloning entity with ClassMetadata
by terryb
I am attempting to write a utility method to clone an entity using Hibernate ClassMetadata. my entities extend a EntityBase class which holds few common properties and methods. The problem is that the classMetadata.getPropertyValues(...) method throws exception when it tries to access getter method for property defined in the superclass.
Any way to resolve this????
Exception
| Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of au.edu.tisc.entity.EntityBase.insertDate
|
| Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of au.edu.tisc.entity.EntityBase.insertDate
|
| at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
| at org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValues(AbstractEntityTuplizer.java:256)
| at org.hibernate.tuple.entity.PojoEntityTuplizer.getPropertyValues(PojoEntityTuplizer.java:209)
| at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyValues(AbstractEntityPersister.java:3576)
| at au.edu.tisc.session.CloneEntity.clone(EntityCloner.java:48)
| ....
| ....
|
| Snippet from my EntitCloner utility class
|
| ...
| ClassMetadata classMetadata = sessionFactory.getClassMetadata(course.getClass());
|
| String[] propertyNames = classMetadata.getPropertyNames();
| /* this works ok and lists all the properties, including those in the EntityBase(mappedSuperclass), as below: */
| [insertDate,lastUpdateDate,code...]
|
|
| Object[] propertyValues = classMetadata.getPropertyValues(this.sourceEntityClass, EntityMode.POJO);
| /* this throws exception ?????????? as it tries to find/access/trace/? getter method for insertDate property */
| ...
|
|
| @Entity
| @Table(name = "Course")
| public class Course extends EntityBase implements java.io.Serializable {
|
| private String code;
| private CourseStatus courseStatus;
| private Set<Preference> preferences = new HashSet<Preference>(0);
| ...
|
| public Course() {}
|
| public Course(String id, String code, CourseStatus courseStatus, Date lastUpdateDate, Date insertDate, Set<Preference> preferences ...) {
|
| super(id, lastUpdateDate, insertDate);
| this.courseStatus = courseStatus;
| this.code = code;
| this.preferences = preferences;
| ...
| }
|
| @Column(name = "Code", nullable = false, length = 20)
| @NotNull
| @Length(min = 5, max = 5)
| public String getCode() {
| return this.code;
| }
|
| public void setCode(String code) {
| this.code = code;
| }
|
| @ManyToOne(fetch = FetchType.LAZY)
| @JoinColumn(name = "CourseStatusID")
| public CourseStatus getCourseStatus() {
| return this.courseStatus;
| }
|
| public void setCourseStatus(CourseStatus courseStatus) {
| this.courseStatus = courseStatus;
| }
|
| @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "course")
| public Set<Preference> getPreferences() {
| return this.preferences;
| }
|
| public void setPreferences(Set<Preference> preferences) {
| this.preferences = preferences;
| }
| ...
| }
|
|
| @MappedSuperclass
| public abstract class EntityBase {
| private String id;
| private Date lastUpdateDate;
| private Date insertDate;
|
| public EntityBase () {
| super();
| }
|
| public EntityBase (String id) {
| super();
| this.id = id;
| }
|
| public EntityBase(String id, Date lastUpdateDate, Date insertDate) {
| super();
| this.id = id;
| this.lastUpdateDate = lastUpdateDate;
| this.insertDate = insertDate;
| }
|
| @Id
| @GenericGenerator(strategy="au.edu.tisc.session.OnlineKeyGenerator", name="onlineKeyGen")
| @GeneratedValue(generator="onlineKeyGen")
| @Column(name = "ID", unique = true, nullable = false, length = 20)
| public String getId() {
| return id;
| }
|
| public void setId(String id) {
| this.id = id;
| }
|
| @Column(name = "LastUpdateDate", length = 23)
| public Date getLastUpdateDate() {
| return lastUpdateDate;
| }
|
| public void setLastUpdateDate(Date lastUpdateDate) {
| this.lastUpdateDate = lastUpdateDate;
| }
|
| @Column(name = "InsertDate", length = 23)
| public Date getInsertDate() {
| return insertDate;
| }
|
| public void setInsertDate(Date insertDate) {
| this.insertDate = insertDate;
| }
| ...
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165494#4165494
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165494
17 years, 9 months
[Installation, Configuration & DEPLOYMENT] - Re: Error in shutdown using jboss_init_redhat.sh
by thalupula
Hi Peter,
I done with shutdown by following your instructions, Now i'm focusing on the exception. How can i resolve below error. Any configurations required at run.sh file?
04:03:34,829 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract void javax.jms.MessageListener.onMessage(javax.jms.Message), causedBy:
javax.ejb.EJBException: Unexpected Error
java.lang.OutOfMemoryError: PermGen space
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:237)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:109)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:402)
at org.jboss.ejb.Container.invoke(Container.java:960)
at sun.reflect.GeneratedMethodAccessor87.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
at org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor.delivery(MessageEndpointInterceptor.java:263)
at org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor.invoke(MessageEndpointInterceptor.java:140)
at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
at $Proxy85.onMessage(Unknown Source)
at com.ibm.mq.connector.inbound.MessageEndpointWrapper.onMessage(MessageEndpointWrapper.java:124)
at com.ibm.mq.jms.MQSession.run(MQSession.java:1592)
at com.ibm.mq.connector.inbound.WorkImpl.run(WorkImpl.java:142)
at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
at java.lang.Thread.run(Thread.java:595)
Regards,
Ravi Thalupula
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165485#4165485
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165485
17 years, 9 months