-->
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: Key composed
PostPosted: Thu Apr 24, 2008 8:58 am 
Newbie

Joined: Thu Apr 24, 2008 8:32 am
Posts: 1
Location: Brazil
Hi all!
Firstly, excuse my english!


Class Empresa
Code:
@Entity
public class Empresa {
@Id   @GeneratedValue
private Integer   empresa;
set/get
}


Class Pessoa Pk is composed by Empresa and Integer
Code:
@Entity
public class Pessoa{
@EmbeddedId
private PessoaId   pessoaId;
set/get
}


Class PessoaId
Code:
@Embeddable
public class PessoaId implements Serializable{
@ManyToOne
@JoinColumn(name="empresa")
private Empresa empresa;
private Integer pessoa;
set/get
}


I need that primary key of the Class Funcionario is a Foreing Key of the Class Pessoa
Class FuncionarioId
Code:
@Embeddable
public class FuncionarioId implements Serializable{
@ManyToOne
@JoinColumn(name="empresa")
private Empresa empresa;

//My doubt is here, I Don't know do this anotation, I need that Id (Pk) of Funcionario is a Foreing Key of the Class Pessoa
set/get
}


Class Funcionario
Code:
@Entity
public class Funcionario{
@EmbeddedId
private FuncioarioId   funcionarioId;
set/get
}


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.