Hallo,
I am using an Hibernate and JBoss Cache as second level cache. The example entity has an @Transient field number:
Code:
@Entity
public class Foo {
@Column(length=20)
private String name;
@Transient
private Integer number;
}
TestCode:
Code:
Foo foo = new Foo();
foo.setName("Paul");
foo.setNumber(Integer.valueOf(55));
foo = entityManager.persist(foo);
Assert.assertEquals(55, foo.getNumber().intValue());
The assertion fails because foo.getNumber() is null. This is a reasonable behavior if you think about persisting an object. If you look the other way, putting something into a cache an read it again, this behavior is strange.
Is there a way to configure Jboss Cache/Hibernate to change this behavior?
I am using Jboss Cache (1.4.1.SP9), Hibernate 3.2.1 from within JBoss AppServer 4.2.3
Thanks for your help.
Viktor