-->
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.  [ 6 posts ] 
Author Message
 Post subject: Field/property access defined per field
PostPosted: Thu Jun 23, 2005 5:37 am 
Newbie

Joined: Tue May 31, 2005 8:57 am
Posts: 10
Hi,

Is it possible with EJB 3.0 (or Hibernate) annotations to specify access strategies per field? I have an id field with only a getter since a setter seems weird for an assigned primary key. So I'd like to specify to my id field should be accessed by field. However, my other properties should be accessed by property get/set.

I can only find the class-level @Entity annotation where AccessType can be set, no field-level annotations.

My class file is like this:
Code:
@Entity(access = AccessType.PROPERTY)
public class Term {
   @Id
   private Long id;
   private String otherProperty;

   public Long getId() { return id; }
   
   public String getOtherProperty() { return otherProperty; }
   public void setOtherProperty(String param) { otherProperty = param; }
}


How do I specify that id is accessed by field and otherProperty by property?

Regards,
Ronald Wildenberg


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 5:46 am 
Newbie

Joined: Tue May 31, 2005 8:57 am
Posts: 10
Of course it is possible to define a method
Code:
private void setId(Long id) { this.id = id; }
to solve this particular problem (which I have done for now like this), but then the question still holds whether field-specific access types can be defined.

Regards,
Ronald Wildenberg


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 9:13 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
access type is only class level

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 10:31 am 
Newbie

Joined: Tue May 31, 2005 8:57 am
Posts: 10
Ok, but if I use xml mappings, I can specify an access attribute per property element. I was expecting something similar to be possible using annotations.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 10:42 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Well, that's life :-)
I'll probably enhance that at some point when I'll allow custom access strategy, but I don't have the time right now. Contributions always welcome.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 04, 2005 3:33 am 
Newbie

Joined: Tue May 31, 2005 8:57 am
Posts: 10
Well, I'm a little short of spare time myself, so don't count on any contributions :)

Good luck.


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