Results 1 to 2 of 2
- 05-17-2011, 09:25 AM #1
Member
- Join Date
- May 2011
- Posts
- 1
- Rep Power
- 0
How to Do One to Many Mapping in JPA For this scenario
I have a class
public class ExamCategoryDTO {
@Id
private Long id;
@OneToMany(mappedBy = "examCategoryDTO", targetEntity = ExamNameDTO.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<ExamNameDTO> examNameList;
}
And another class
public class ExamNameDTO {
@Id
private Long id;
@Column(name="EXAM_CATEGORY_ID")
private Long examCategoryId;
@ManyToOne
@JoinColumn(name = "EXAM_CATEGORY_ID")
private ExamCategoryDTO examCategoryDTO;
}
If i do like this it gives error saying that EXAM_CATEGORY_ID is alearady mapped. I need to know the way to save ExamNameDTO without ExamCategoryDTO and i want to sent the Foreign key in ExamNameDTO manuaaly and Some times i want to save thru ExamCategoryDTO and in that case it will have ExamCategoryDTO as list. I want to do bothways. How can i do that. Please help
- 05-19-2011, 08:48 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
Can somebody please help me with a "tie" scenario...URGENT
By university123 in forum New To JavaReplies: 2Last Post: 10-25-2010, 11:58 AM -
Castor Mapping - Help
By roddy in forum XMLReplies: 1Last Post: 08-27-2009, 01:25 AM -
XML and Database Mapping in .NET
By gilbertsavier in forum XMLReplies: 0Last Post: 07-17-2009, 07:34 AM -
Servlet mapping
By cozsmin in forum Java ServletReplies: 1Last Post: 04-04-2009, 09:15 AM -
Scenario
By ron87 in forum New To JavaReplies: 1Last Post: 04-01-2009, 05:14 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks