-->
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: PropertyAccessException ???
PostPosted: Mon Nov 13, 2006 9:40 am 
Newbie

Joined: Mon Nov 13, 2006 9:04 am
Posts: 3
Hi guys

I get the following error, when I try to save the entity B:


session.saveOrUpdate(B);



org.hibernate.PropertyAccessException: could not get a field value by reflection getter of A.id


I´m using Hibernate 3.

<class name="A" schema="S" table="A">
<id name="id" column="A_ID">
<generator class="increment">
<param name="schema">S</param>
</generator>
</id>
<property name="number" column="NUMBER" not-null="true" length="3"/>
</class>


<class name="B"
schema="S" table="B">
<id name="id" column="B_ID">
<generator class="increment">
<param name="schema">S</param>
</generator>
</id>
<property name="description" column="DESCRIPTION" />
<list name="mybs" schema="STRECKE" table="B_A">
<key column="B_id"/>
<list-index column="B_A_id"/>
<many-to-many column="A_id" class="A"/>
</list>


class A {
private int id;
private setId(int id) {this.id=id;}
private int getId() {return this.id;}
private String number;
private setNumber(String id) {this.number=number;}
private String getNumber() {return this.number;}
}

class B {
private int id;
private setId(int id) {this.id=id;}
private int getId() {return this.id;}
private String description;
private setDescription(String description) {this.description=description;}
private String getDescription() {return this.description;}
List mybs;
public String getMybs() {return this.mybs;}
public void setMybs(String mybs) {this.mybs = mybs;}

}


What´s wrong here???

Any hints will be kindly appreciated.

Thx


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 9:54 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Your getters and setters are private. Try making them public or switch to access=field

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 10:34 am 
Newbie

Joined: Mon Nov 13, 2006 9:04 am
Posts: 3
oh sorry mike you´re right. I did miss it to pass the right code snip. The methods were already defined as public.

here is it:
class A {
private int id;
public setId(int id) {this.id=id;}
public int getId() {return this.id;}
private String number;
public setNumber(String id) {this.number=number;}
public String getNumber() {return this.number;}
}

class B {
private int id;
public setId(int id) {this.id=id;}
public int getId() {return this.id;}
private String description;
publicsetDescription(String description) {this.description=description;}
publicString getDescription() {return this.description;}
private List mybs;
public String getMybs() {return this.mybs;}
public void setMybs(String mybs) {this.mybs = mybs;}

}

And I´ve already tried the field access variant:

<hibernate-mapping default-access="field">

I get the same error:


org.hibernate.PropertyAccessException: could not get a field value by reflection getter of A.id
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:34)
at org.hibernate.tuple.AbstractTuplizer.getIdentifier(AbstractTuplizer.java:103)
at org.hibernate.persister.entity.BasicEntityPersister.getIdentifier(BasicEntityPersister.java:2944)
at org.hibernate.persister.entity.BasicEntityPersister.isTransient(BasicEntityPersister.java:2705)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:215)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:99)
at org.hibernate.type.EntityType.replace(EntityType.java:194)
at org.hibernate.type.CollectionType.replaceElements(CollectionType.java:399)
at org.hibernate.type.CollectionType.replace(CollectionType.java:420)
at org.hibernate.type.TypeFactory.replace(TypeFactory.java:385)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:239)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsPersistent(DefaultMergeEventListener.java:125)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:106)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:54)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:539)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 10:53 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Is that the complete StackTrace?

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 11:12 am 
Newbie

Joined: Mon Nov 13, 2006 9:04 am
Posts: 3
org.hibernate.PropertyAccessException: could not get a field value by reflection getter of A.id
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:34)
at org.hibernate.tuple.AbstractTuplizer.getIdentifier(AbstractTuplizer.java:103)
at org.hibernate.persister.entity.BasicEntityPersister.getIdentifier(BasicEntityPersister.java:2944)
at org.hibernate.persister.entity.BasicEntityPersister.isTransient(BasicEntityPersister.java:2705)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:215)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:99)
at org.hibernate.type.EntityType.replace(EntityType.java:194)
at org.hibernate.type.CollectionType.replaceElements(CollectionType.java:399)
at org.hibernate.type.CollectionType.replace(CollectionType.java:420)
at org.hibernate.type.TypeFactory.replace(TypeFactory.java:385)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:239)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsPersistent(DefaultMergeEventListener.java:125)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:106)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:54)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:539)
at PDAOImpl.saveB(PDAOImpl.java:1229)
at PFacadeImpl.saveBAssignment(PFacadeImpl.java:1770)
at PAction.saveBAssignment(PAction.java:993)
at PAction.execute(PAction.java:164)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at de.fuer_sie_eg.net.stats.web.TrackingFilter.doFilter(TrackingFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.IllegalArgumentException
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
at java.lang.reflect.Field.get(Field.java:228)
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:31)
... 58 more


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.