-->
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.  [ 2 posts ] 
Author Message
 Post subject: help: How to persist the following Inheritance classes?
PostPosted: Sun Oct 10, 2004 11:03 pm 
Newbie

Joined: Sun Oct 10, 2004 10:35 pm
Posts: 1
Hi, every one.
I am a Hibernate beginner, now I need to persist the following Inheritance classes.
Entity (inteerface)
|
AbstractEntity (an abstract implementation to Entity)
/ | \
Concrete Entityies

The root node of the inheritance tree is "Entity", it is an interface, then I give its an abstract implementation --AbstractEntity,which every concrete entity inherited from.

Code:

public interface Entity
    extends Serializable {

  //
  public String getUUID();

  //
  public void setUUID(String uuid);
}

public abstract class AbstractEntity
    implements Entity {

  //
  protected AbstractEntity() {
  }

  //
  protected AbstractEntity(String uuid) {
    setUUID(uuid);
  }

  //
  private String uuid;

  //
  public String getUUID() {
    return uuid;
  }

  //
  public void setUUID(String uuid) {
    this.uuid = uuid;
  }
}


The following is a sample concrete entity :
Code:
public class DD extends AbstractEntity  {

    /** identifier field */
    private String uuid;

    /** nullable persistent field */
    private String ssjwq;

    /** nullable persistent field */
    private String sspcs;

    /** nullable persistent field */
    private String ssxzqh;

    /** nullable persistent field */
    private String szddz;

    /** nullable persistent field */
    private String szdxz;

.....
}


we know that the Entity and AbstractEntity needn't be persisted to database, every concrete entity need to be persisted to database.

Hibernate have 3 strategies for inheritance mapping:
    A.one table per class hierarchy
    B.one table per subclass
    C.one table per concrete class


in my opinion, strategy A and stragety B are not right to this case. the only choose is strategy C. But, I don't master the usage of the any tag in hibernate.so I don't know how to write the mapping file.
Can you give me some hint or write the mapping file for me?

Thank you very much.

Aotian


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 11, 2004 1:59 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Read Hibernate in Action, section 3.6

HTH
Ernst


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