-->
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.  [ 1 post ] 
Author Message
 Post subject: Access Strategies: @Embeddable and Properties
PostPosted: Wed Nov 21, 2007 1:20 pm 
Newbie

Joined: Thu Nov 15, 2007 1:36 pm
Posts: 12
Location: Ahsburn, VA
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.