Hibernate Transient Extends problem

Posted by mrvreddy on Stack Overflow See other posts from Stack Overflow or by mrvreddy
Published on 2010-04-08T08:13:24Z Indexed on 2010/04/08 8:23 UTC
Read the original article Hit count: 198

Filed under:
|
|
|
|
@MappedSuperclass
public abstract class BaseAbstract implements Serializable{

 private static final long serialVersionUID = 1L;

 protected String test = //some random value;

 public String getTest() {
  return test;
 }

 public void setTest(String test){
  this.test = test;
 }
}


@Entity
public class Artist extends BaseAbstract
{
  private static final long serialVersionUID = 1L;
  private Integer id;

        @override
 @Transient
 public String getTest() {
  return test;
 }
.....
}

My question is... when i am trying to do any operation on the artist, along with id and name, test is also getting saved which should not be the case...

if i add the same transient on the baseabstract class getTest() method, i see test column NOT getting created(ideally what it should happen) but if i try to override the method with adding annotaion in the sub class it creates the test column...

I dont know why this is happening since when hibernate is creating the artist object and checks for annotations, it should see the transient annotation present on the getTest() of artist method...and should not create a column in the database...

Let me know if you need any clarification....

Any response on this is greatly appreciated....

Thank you

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about jpa