[jboss-user] [Beginners Corner] - Using the persistence manager in an entity bean
nes
do-not-reply at jboss.com
Tue Mar 11 10:54:16 EDT 2008
Greetings!
I have an entity bean called person which has a 1:n relationship to another entity bean called job, which contains all jobs that this person has ever had.
now, i'd like to have a function in person, which gives me only one of these jobs, namely the one he's currently working for.
i did it already, and it nearly works, it looks like this:
Job s;
@Transient
public Stelle getCurrentJob() {
if(s==null){
EntityManager em = (EntityManager) Component.getInstance("entityManager");
Long sid = (Long) em.createQuery("fanceql").setParameter("id", this.id).getSingleResult();
s = em.find(Job.class,sid);
}
return s;
}
The problem is, that changes to Job are not saved to the database. why aren't they?
is this bad design? how would you do it?
niko
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4135642#4135642
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4135642
More information about the jboss-user
mailing list