• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Hibernate problem

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am getting an exception in my Hibernate exception. Below is the stack trace of my exception.

he following exception was logged org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.javacertificate.data.table.Exam.setField1
at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValuesWithOptimizer(PojoEntityTuplizer.java:215)
at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:185)
at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3232)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
................................


This is my database details for this field.

+---------------+--------------+------+
| Field | Type | Null |
+---------------+--------------+------+
| FIELD1 | bigint(20) | YES |
+---------------+--------------+------+

my mapping is

<property name="field1" type="long">
<column name="FIELD1" />
</property>

and following is my java class.

private long field1;

public long getField1() {
return field1;
}

public void setField1(long field1) {
this.field1 = field1;
}

How can I resolve this issue ?
[ May 26, 2006: Message edited by: Albin Joseph ]
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could the problem be that the database column allows NULL, but you are using a java primitive long value.

try using the java.lang.Long for the property in your class.

i.e.

private Long field1;

public void setField1(Long value) { this.field1 = value; }
public Long getField1() { return this.field1; }
 
Travis Hein
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>following exception was logged org.hibernate.PropertyAccessException: >exception setting property value with CGLIB (set >
>hibernate.cglib.use_reflection_optimizer=false for more info) set

Also noticed this,

Hibernate does some internal optimization by default the error message is telling us that if we turn this optimization off, we may be able to get a more specific message or more hints to what the problem is.

in the hibernate.properties you can set
hibernate.cglib.use_reflection_optimizer=false

(at least temporarily for debugging)
Then try to do the things you did before and see if the error message is different.
 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to bring the post to a logical conclusion:

I encountered the same problem today and found out that Travis' suggestion of converting the primitive to wrapper (Long) class did the trick.

As for the second suggestion, it did print a whole lot more when the value of hibernate.bytecode.use_reflection_optimizer is changed but the error messages were not particularly helpful.

Saket
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i had this same problem but with a boolean field. i changed the boolean getter/setters to be Boolean (capital B ). I also made a check in my getter to firstly check if the field was null and if it was return false.

-another option as already stated is to update all the null values to be false in the table.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by madison:
i had this same problem but with a boolean field. i changed the boolean getter/setters to be Boolean (capital B ). I also made a check in my getter to firstly check if the field was null and if it was return false.

-another option as already stated is to update all the null values to be false in the table.



"Maddison"

Please click on the My Profile link above and change your display name to meet the JavaRanch Naming Policy of using your real first and real last names.

Thanks

Mark
reply
    Bookmark Topic Watch Topic
  • New Topic