I have two tables where there is a one to many relationship between those tables. here is a tables: Category table (Parent table)
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@Column(name="CATEGORY_NAME")
private String categoryName;
//bi-directional many-to-one association to TmCategoryPropertiesMapping
@OneToMany(mappedBy="tmCategory", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Set<TmCategoryPropertiesMapping> tmCategoryPropertiesMappings;
.............
....... getter and setters
and the other entity: category Mapping table (child table)
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@Column(name="CREATED_BY")
private BigInteger createdBy;
@Column(name="CREATED_DATE")
private Timestamp createdDate;
@Column(name="PROPERTY_ID")
private BigInteger propertyId;
//bi-directional many-to-one association to TmCategory
@ManyToOne
@JoinColumn(name="CATEGORY_ID")
private TmCategory tmCategory;
Here if I get the categories using owner ID I am getting duplicates in my result.
Even though I have only 3 entries in category table but I am getting 10 entities in my result.
What is the reason for this?
any how can I overcome from this?
The table data is here:
The result I get here is id= 1,1,2,2,2,3,3,3,3