How to do @OneToMany mapping on the field using @transient
Posted
by hemal
on Stack Overflow
See other posts from Stack Overflow
or by hemal
Published on 2010-03-12T05:24:57Z
Indexed on
2010/03/12
5:27 UTC
Read the original article
Hit count: 218
I am using JPA annotations here , I want to do @OneToMany mapping on filed declared as @Transient. is it possible to do mapping on @transient field ?
- SimpleTagGroup.java
@Entity @Table(name = "TagGroup") public class SimpleTagGroup {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id = -1;
@NotNull
private String tagGroupName;
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name = "TagMapping", joinColumns =
@JoinColumn(name = "id"), inverseJoinColumns =
@JoinColumn(name = "tagId"))
@Transient
private List<SimpleTag> tags;
- SimpleTag.java
@Entity @Table(name = "Tag") public class SimpleTag implements Tag{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id = -1;
@NotNull
private String tagValue;
© Stack Overflow or respective owner