With regard to Access Strategies, I know that an entity can be persisted using:
- Its members, via @Entity, or
- Its accessors, via @Entity(access=AccessType.PROPERTY)
I've currently got a member-persisted entity that has an @Embedded class.
The @Embeddable class, however, has a lot of members that I don't want persisted (all marked at @Transient). Its sole purpose is to provide a single public getter/setter which results in a string.
It is
that dynamically string that I need persisted in a column, inside my containing entity.
What's the right way of doing this?
If it was possible to mark a class as
@Embeddable(access=AccessType.PROPERTY), I'd be set.
Hibernate version:
Hibernate 3.2.5 / Hibernate Annotations 3.3.0.GA
Code illustation:
Code:
@Entity
public class A {
@Id @Generatedvalue private Long id; // Hibernate surrogate key
@Embedded
B b = new B();
// Other private members that persist perfectly fine
...
}
@Embeddable
public class B {
// Dozens of transient members used as place holders during work
...
@Column( name="MagicString" )
public getMagicString() { return /*...ugly computations...*/; }
public setMagicString( String s) { /*...ugly parsing...*/; }
}
Thanks,
Walt Stoneburner