-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate should only "see" annotated getters
PostPosted: Thu May 04, 2006 9:03 am 
Regular
Regular

Joined: Fri Jan 20, 2006 9:38 am
Posts: 61
Location: Notts, UK
I have a problem with an EJB3 persistent entity - "User".

I have added a getter (getContact()) which gets a derived piece of information from the object.

On deployment, I get the following error:

Code:
Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property contact in class com.fcl.greenfield.entity.
User
        at org.hibernate.property.BasicPropertyAccessor.createSetter(BasicPropertyAccessor.java:216)
        at org.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:209)
        at org.hibernate.mapping.Property.getSetter(Property.java:256)
        at org.hibernate.tuple.PojoEntityTuplizer.buildPropertySetter(PojoEntityTuplizer.java:259)
        at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:122)
        at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
        at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
        at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
        at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
        at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:414)
        at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:575)
        at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:245)
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:108)
        at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:260)


It should NOT be doing this. It's a read-only property. Hibernate should only look at getters/setters which are annotated as database columns. It's interfering!

Is there a way of avoiding this, or do I have to violate standards, and make my method extractContact()?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 9:41 am 
Regular
Regular

Joined: Fri Jan 20, 2006 9:38 am
Posts: 61
Location: Notts, UK
Found it. @Transient needed.

The Javadocs for the annotations are totally blank, they don't explain what they do AT ALL!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 9:42 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
hibernate/cglib looks up only those properties which are specified in your mapping file.
Obviously your User class has no method setContact()

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 10:21 am 
Regular
Regular

Joined: Fri Jan 20, 2006 9:38 am
Posts: 61
Location: Notts, UK
axismundi wrote:
hibernate/cglib looks up only those properties which are specified in your mapping file.
Obviously your User class has no method setContact()


I have no mapping file. I'm using EJB3 annotations to specify which getters correspond to database columns.

I contend that unannotated getters should be ignored.

The "contact" property is indeed read-only.


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