-->
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: PropertyAccessException for id field when persisting object
PostPosted: Wed May 13, 2009 6:53 am 
Beginner
Beginner

Joined: Sun Sep 19, 2004 5:02 pm
Posts: 28
Location: Poland
Entity:

public class LogEntity {

private Integer id;

private Date time;

private String level;

private String logger;

private String login;

private String message;

private String exception;

public LogEntity() {}

public LogEntity(Date time, String level, String logger) {
this.time = time;
this.level = level;
this.logger = logger;
}

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Date getTime() {
return time;
}

public void setTime(Date time) {
this.time = time;
}

public String getLevel() {
return level;
}

public void setLevel(String level) {
this.level = level;
}

public String getLogger() {
return logger;
}

public void setLogger(String logger) {
this.logger = logger;
}

public String getLogin() {
return login;
}

public void setLogin(String login) {
this.login = login;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public String getException() {
return exception;
}

public void setException(String exception) {
this.exception = exception;
}

}

Mapping:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
version="1.0">

<persistence-unit-metadata>
<persistence-unit-defaults>
<access>FIELD</access>
</persistence-unit-defaults>
</persistence-unit-metadata>

<package>logging</package>

<entity class="LogEntity">
<table name="LOG"/>
<sequence-generator name="LOG_SEQUENCE" sequence-name="LOG_SEQ" allocation-size="100"/>
<attributes>
<id name="id">
<generated-value strategy="SEQUENCE" generator="LOG_SEQUENCE"/>
</id>
<basic name="time">
<column nullable="false"/>
<temporal>TIMESTAMP</temporal>
</basic>
<basic name="level">
<column name="XLEVEL" nullable="false" length="20"/>
</basic>
<basic name="logger">
<column nullable="false" length="100"/>
</basic>
<basic name="login">
<column length="255"/>
</basic>
<basic name="message">
<column length="2000"/>
</basic>
<basic name="exception">
<lob/>
</basic>
</attributes>
</entity>

</entity-mappings>

Config:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd" version="1.0">

<persistence-unit name="LogPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>jdbc/LogDataSrc</non-jta-data-source>
<mapping-file>META-INF/log_orm.xml</mapping-file>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.jdbc.batch_size" value="10" />
</properties>
</persistence-unit>
</persistence>

Stack trace:

Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of
portal.logging.LogEntity.id
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226)
at portal.logging.JPAAppender.flushBuffer(JPAAppender.java:130)
... 22 more
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of pl.nbp.portal.logging.LogEntity.id
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:58)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:206)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3619)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3335)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:535)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:93)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:645)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:619)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:623)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220)
... 23 more
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Integer field pl.nbp.portal.logging.LogEntity.id to pl.nbp.portal.logging.LogEntity
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
at java.lang.reflect.Field.get(Field.java:358)
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:55)
... 34 more

System:
Java 1.6_02
Hibernate Core 3.3.1.GA

_________________
Lmichasz


Top
 Profile  
 
 Post subject: Re: PropertyAccessException for id field when persisting object
PostPosted: Wed May 13, 2009 7:36 am 
Newbie

Joined: Wed Jan 21, 2009 4:26 pm
Posts: 12
I guess LogEntity implements Serializable is missing


Top
 Profile  
 
 Post subject: Re: PropertyAccessException for id field when persisting object
PostPosted: Thu May 14, 2009 4:22 am 
Beginner
Beginner

Joined: Sun Sep 19, 2004 5:02 pm
Posts: 28
Location: Poland
Why? I don't thing so.
I can't check it becouse this error occurs from time to time and I have no 100% test case to reproduce it.
I use this in Weblogic 10.3 and I have oslo other problem - the following warnig also occurs form time to time.

"WARNING: Found unrecognized persistence provider "org.hibernate.ejb.HibernatePersistence" in place of OpenJPA provider. This provider's properties will not be used."

I think this could be connected with above error.

_________________
Lmichasz


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.