-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Composite element with a nested <many-to-one>
PostPosted: Fri Apr 08, 2005 4:47 pm 
Beginner
Beginner

Joined: Thu Feb 17, 2005 4:20 pm
Posts: 29
I am trying to model a many-to-many relationship with a composite element and a many-to-one tag, but am getting an error. Any help would be appreciated.

I have a User, Role and UserRole tables. The UserRole table holds the many-to-many relationship. I am only interested in the one way mapping - there is no mapping to the User from the Role object.

In the User mapping file:

Code:
<set name="roles" table="USER_ROLE" cascade="all-delete-orphan">
  <key column="USER_ID"/>
  <composite-element class="com.biperf.core.domain.user.UserRole">
      <property name="createdBy" column="CREATED_BY" type="java.lang.String" />
      <many-to-one name="role" class="com.biperf.core.domain.user.Role"  />
  </composite-element>
</set>


The UserRole class:

Code:
public class UserRole
{
  private Role role;
  private User user;
  private String createdBy;

  //getters and setters removed in post...

}



The exception I am getting on a session.flush():

Code:
org.hibernate.PropertyAccessException: exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of com.biperf.core.domain.user.UserRole.?
   at org.hibernate.tuple.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:42)
   at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:257)
   at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:252)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:757)
   at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:860)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:739)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:817)
   at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:121)
   at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:112)
   at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:59)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)
   at com.biperf.core.dao.hibernate.BaseDAOTest.tearDown(BaseDAOTest.java:86)
   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 junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at junit.textui.TestRunner.doRun(TestRunner.java:116)
   at com.intellij.rt.execution.junit2.IdeaJUnitAgent.doRun(IdeaJUnitAgent.java:57)
   at junit.textui.TestRunner.start(TestRunner.java:172)
   at com.intellij.rt.execution.junit.TextTestRunner2.startRunnerWithArgs(TextTestRunner2.java:23)
   at com.intellij.rt.execution.junit2.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:97)
   at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
   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:324)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.lang.ClassCastException
   at com.biperf.core.domain.user.UserRole$$BulkBeanByCGLIB$$5cae029d_2.getPropertyValues(<generated>)
   at net.sf.cglib.beans.BulkBean.getPropertyValues(BulkBean.java:48)
   at org.hibernate.tuple.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:39)


Am I missing something?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 6:24 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Yep, why don't you try this one
Quote:
exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of com.biperf.core.domain.user.UserRole.?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 9:35 am 
Beginner
Beginner

Joined: Thu Feb 17, 2005 4:20 pm
Posts: 29
emmanuel wrote:
Yep, why don't you try this one
Quote:
exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of com.biperf.core.domain.user.UserRole.?


I tried that. It did not give me anything more information. I.E. identical stack trace.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 9:36 am 
Beginner
Beginner

Joined: Thu Feb 17, 2005 4:20 pm
Posts: 29
The question is why is Hibernate looking for a getter for "?" ?

Code:
getter of com.biperf.core.domain.user.UserRole.?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 14, 2005 10:33 am 
Beginner
Beginner

Joined: Thu Feb 17, 2005 4:20 pm
Posts: 29
For anyone who is interested, I found the source of my problem. I was adding a Role object to the roles set in User instead of a UserRole object to the roles set.

Boy do I feel dumb....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.