-->
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.  [ 3 posts ] 
Author Message
 Post subject: Using a mapped object in a transient method?
PostPosted: Tue Nov 18, 2008 4:34 am 
Beginner
Beginner

Joined: Fri Nov 14, 2008 7:11 am
Posts: 31
Hi,

I am relativ new to Hibernate and though have a question.
Is it allowed / a good style to have a transient method in one entity that is calculating something and therefore is using an instance of a mapped object?

For example:

Code:
public class A
{
  private Long id;
  private String s;
  private Integer i;
  private B b;

  [...] getter and setter

  @ManyToOne(optional = false, fetch = FetchType.EAGER)
  public B getB()
  {
    return b;
  }

  @Transient
  public Integer calculate()
  {
    return i - b.getI2(); // IS THIS ALLOWED?
  }
}




Code:
public class B
{
  private Long id;
  private Integer i2;

  [...] getter and setter
}


Thanks in advance,
Ole


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 6:18 am 
Beginner
Beginner

Joined: Fri Nov 14, 2008 7:11 am
Posts: 31
push


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 6:19 am 
Beginner
Beginner

Joined: Fri Nov 14, 2008 7:11 am
Posts: 31
push


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