-->
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: Only AccessType.PROPERTY works ?
PostPosted: Mon Sep 26, 2005 8:38 am 
Newbie

Joined: Mon Sep 26, 2005 7:32 am
Posts: 2
Hibernate version:
Hibernate 3.1beta3
Hibernate Annotations 3.1beta5
Hibernate Entitymanager 3.1beta3

Name and version of the database you are using:
embedded hsqldb

I am testing the Entitymanager in a j2se environment.

My class works with @Entity(access=AccessType.PROPERTY)
and @Id(generate = GeneratorType.AUTO).
However, if I switch to @Entity(access = AccessType.FIELD) annotation,
the ID Generator isn't called and I get a

org.hibernate.PropertyValueException: not-null property references a null or transient value:

Exception.

The hibernate create table sql statement etc. are the same as the PROPERTY annotation.

Does anybody have a similiar problem ?"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 10:19 am 
Beginner
Beginner

Joined: Sat Sep 17, 2005 10:41 am
Posts: 49
I'm using AccessType.FIELD all over the place, but never the GeneratorType.AUTO. Just one thing: make sure you put the @Id annotation right before the member field (as opposed to the getXXX method).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 10:49 am 
Newbie

Joined: Mon Sep 26, 2005 7:32 am
Posts: 2
I think it makes no difference which GeneratorType I use
as the generator is used with PROPERTY annotation.

And yes I'm sure that I put all annotation for both tests in the right place.

I'm using other annotations (@Colum(nullable = false, length = ....) etc. and all this annotations are ok with FIELD and PROPERTY annotation.

The only problem is, I didn't get an ID if I use FIELD annotation.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 11:11 am 
Beginner
Beginner

Joined: Sat Sep 17, 2005 10:41 am
Posts: 49
Post your code... it might be a simple oversight.


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.