-->
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: Hibernate-mapping-inheritance
PostPosted: Wed Sep 21, 2011 11:09 am 
Newbie

Joined: Thu Feb 17, 2011 5:08 pm
Posts: 6
Hello, I'm trying to map some objects in Hibernate. One of these objects is father and the others are children. In other words they implement inheritance.
The father is as follow:
Code:
public class Person {
  private String id;
  private String name;
  private String surname;

getters and setters;

}


and children...
Code:
public class Employee {
      private BigDecimal salary;
      private String seccion;
      private Employee employee;
      private  Customer customer;

  getters and setters
}

public class Customer {
     private BigDecima CreditLimit;

getter and setter
}


Then... I want to map these classes in the following database schema...

Table
Person
ID / NAME / SURNAME / ID_EMPLOYEE / ID_CUSTOMER

Employee
ID_PERSON / SALARY / SECCION

Customer
ID_PERSON / CREDIT_LIMIT


My idea is each persona can be or not a customer/employee. In other words Customer and Employee are properties of Person but these properties will be store in independents tables in the database.

For get the credit limit of a persona I can do persona.getCustomer().getCreditLimit();

Always making control if the Person is a Customer or is not.


I hope you can help me and excuse me my English is pretty poor. I'm from Argentina.

Thanks in advance.

Nicolas


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.