-->
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: Overriding Annotation
PostPosted: Fri May 28, 2010 3:11 pm 
Newbie

Joined: Thu May 27, 2010 10:48 am
Posts: 10
Hello folks, I'm wondering if there is how to override the annotations in a class like this

public class Country {
List stateList;
...
...
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name="country_id")
public List<State> getStateList() {
return stateList;
}
}

public class Address {
Country country;
* I want to override the property stateList in the Class Country. The stateList is not necessary
* in this entity
}

Anyone knows how to do it? thanks.


Top
 Profile  
 
 Post subject: Re: Overriding Annotation
PostPosted: Fri May 28, 2010 3:18 pm 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
@AttributeOverrides

Refrence: http://docs.jboss.org/hibernate/stable/ ... ml_single/


Top
 Profile  
 
 Post subject: Re: Overriding Annotation
PostPosted: Fri May 28, 2010 3:44 pm 
Newbie

Joined: Thu May 27, 2010 10:48 am
Posts: 10
You're fast. I read about this method, it seems to override the column names, but doesn't show how to override annotations. My problem is, when I need someone's address, I don't need a list of states, I just need the Country, that's it. On the other hand, when I need a Country object (to load an option list with states), I do need the list of states.


Top
 Profile  
 
 Post subject: Re: Overriding Annotation
PostPosted: Fri May 28, 2010 3:49 pm 
Newbie

Joined: Thu May 27, 2010 10:48 am
Posts: 10
By the way, if I could override the annotation, I would override it with @Transient, then hibernate would ignore the field (I guess).


Top
 Profile  
 
 Post subject: Re: Overriding Annotation
PostPosted: Fri May 28, 2010 4:22 pm 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
Have you looked into Lazy Fetching? Transient may cause you problems when inserting data I think


Top
 Profile  
 
 Post subject: Re: Overriding Annotation
PostPosted: Fri May 28, 2010 4:45 pm 
Newbie

Joined: Thu May 27, 2010 10:48 am
Posts: 10
Yeah, maybe you're right, maybe hibernate will not allow me to do anyway.


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.