-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate not JPA2 compliant regarding @Access?
PostPosted: Tue Jul 06, 2010 1:34 am 
Newbie

Joined: Sat Dec 05, 2009 1:34 am
Posts: 12
Can anyone confirm this or did I make a stupid mistake somewhere?

According to my JPA 2.0 book (and online documentation), I should be able to mix field and property access within a single entity or entity hierarchy. The annotation @Access on the class specifies the default access -- and when placed on a field or property getter it specifies that the default should be overridden for this one particular field. This class should result in a table with three columns:

Code:
    @Entity
    @Access(AccessType.FIELD)
    Class Foo {

      @Id
      int id;
     
      @Column(name = "myfield")
      String myField;
   
   
      @Column(name = "myProp")
      @Access(AccessType.PROPERTY)
      public int getMyProp () {
        return 3;
      }
   
      public void setMyProp (int p) {
        // do nothing
      }
    }


However it doesn't with Hibernate...the "myProp" column is missing from the table because apparently Hibernate takes its field vs property cue from the entity ID and runs with it...totally ignoring the JPA spec with regards to @Access.

Conversely, if I move the @Id annotation to a getter method, then the annotated field "myField" is ignored.


Top
 Profile  
 
 Post subject: Re: Hibernate not JPA2 compliant regarding @Access?
PostPosted: Wed Jul 07, 2010 12:53 pm 
Newbie

Joined: Sat Dec 05, 2009 1:34 am
Posts: 12
Hello? This is with hibernate 3.5.3-FINAL. Anyone else seeing this?


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