-->
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.  [ 3 posts ] 
Author Message
 Post subject: mapping failure for nested class
PostPosted: Fri Jan 27, 2006 8:29 am 
Newbie

Joined: Fri Jan 27, 2006 8:04 am
Posts: 8
Problem:
Can't set a property on a static inner class.
If I add a getter/setter pair, and set access=property, then the setter is not found

Hibernate version:
3.1.1

Mapping documents:
Code:

<!-- using an existing domain model where many classes are marked
  as final, and setters do not exist always -->
hibernate.cglib.use_reflection_optimizer=false
hibernate.max_fetch_depth=1

<hibernate-mapping default-access="field" default-lazy="false">
   <class name="de.acme.Outer" table="outerTable">
      <id name="id" column="id">
          <generator class="sequence">
                <param name="sequence">SEQ_acme</param>
           </generator>
      </id>
      <many-to-one name="nested" class="de.acme.Outer$Inner" column="innerTable" fetch="join"/>
   </class>
      
   <class name="de.acme.Outer$Inner" table="innerTable">
      <id name="id" column="id"/>
      <property name="customerScore" column="score"/>
   </class>
</hibernate>


java classes

Code:
public final class Outer extends Base
{
  private int id;
  private Outer outer;

  public static class Outer extends Base
  {
    private int id;
    // DB column is NUMBER
    private int customerScore;
  }
}


Full stack trace of any exception that occurs:
Code:
13:15:28.519 INFO [DefaultLoadEventListener]- <Error performing load command>
org.hibernate.PropertyAccessException: could not set a field value by reflection setter of de.acme.OuterClass$InnerClass.customerScore   at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:81)
   at org.hibernate.tuple.AbstractTuplizer.setPropertyValues(AbstractTuplizer.java:207)
   at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:176)
   at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
   at org.hibernate.loader.Loader.doQuery(Loader.java:436)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
   at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
   at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
   at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
   at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
   at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
   at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
   at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
   at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:151)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614)
   at
Caused by: java.lang.IllegalArgumentException
   at sun.reflect.UnsafeIntegerFieldAccessorImpl.set(Unknown Source)
   at java.lang.reflect.Field.set(Unknown Source)
   at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:78)
   ... 36 more


Name and version of the database you are using:
Oracel9i

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 8:56 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
I cannot find the Outer$Inner class in your source code.

You must provide getters and setters for all fields.

Probably not related to your problem but you are missing empty constructors for your classes, which is needed for reflextion (as far I know).

Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject: I take it all back, I never said that
PostPosted: Fri Jan 27, 2006 9:11 am 
Newbie

Joined: Fri Jan 27, 2006 8:04 am
Posts: 8
Surprise, surprise, the problem was not where I expected.

Looks like there are null values in the DB.

Apologies.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.