-->
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: Mapping a Join Table with Additional Columns
PostPosted: Thu Apr 29, 2010 8:20 am 
Newbie

Joined: Thu Apr 29, 2010 8:09 am
Posts: 1
Hi,

In our project we use hibernate annotation. Where in we have a requiremet of manytomany relationship . for example ,
There is employee class with
@Entity
@Table(name="Employee")
public class Employee implements Serializable {

private int empId;
private String empName;
private List<ProjectVo> projects;

@Column(name = "Emp_Name")
public String getEmpName() {
return empName;
}


@Id
@Column(name = "Emp_Id")
public int getEmpId() {
return empId;
}


@ManyToMany // (cascade = {CascadeType.PERSIST, CascadeType.MERGE})

@JoinTable(
name="EMP_PROJ",
joinColumns={@JoinColumn(name="Emp_Id", referencedColumnName="Emp_Id")},
inverseJoinColumns={@JoinColumn(name="PROJ_ID", referencedColumnName="PROJ_ID")})

public List<ProjectVo> getProjects() {
return projects;
}

......

}

And a project class ,
@Entity
@Table(name="ProjectVo")

public class ProjectVo implements Serializable {
private int projectId;
private String projectName;
private List<Employee> employee;


@Column(name="Project_Name")
public String getProjectName() {
return projectName;
}


@ManyToMany(mappedBy="projects")
public List<Employee> getEmployee() {
return employee;
}

@Id
@Column(name="PROJ_ID")
public int getProjectId() {
return projectId;
}

......
}

This will create new table 'EMP_PRJ' with primary keys of 2 tables forming filed in new table (i.e emp_id,project_id).

Our requirement is to add one more column to the 'EMP_PRJ' ,that the mapping table. How we can achieve this .


Thanks in advance
pallavi


Top
 Profile  
 
 Post subject: Re: Mapping a Join Table with Additional Columns
PostPosted: Thu Sep 16, 2010 11:43 am 
Newbie

Joined: Thu Sep 16, 2010 9:35 am
Posts: 2
Location: Germany.Berlin
Hi,

may, you are still locking for a solution ...

please visit:

http://en.wikibooks.org/wiki/Java_Persi ... nnotations


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.