I have entities from tables in database such as:
You see their relationship is one-to-many The IDDot in Dot is an identity column. The IDMS in MaSoDuThuong is an identity column. In normally, i can insert one record into two tables but in other page I need to insert a record into MaSoDuThuong table when i know the value of IDDot . Pls help me do!
Dot dot = entityManager.getReference(Dot.class, dotId);
MaSoDuThuong m = new MaSoDuThuong();
m.setDot(dot);
em.persist(m);
As simple as that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.