hibernate-mapping

Why does JPA OneToOne (even OneToMany) have its orphanRemoval default to false

我是研究僧i 提交于 2020-12-15 05:20:20
问题 Why does JPA OneToOne (or even OneToMany for that matter) have its orphanRemoval default to false . I mean, wouldn't it be better to force the remove operation to entities that have been removed from the relationship and to cascade the remove operation to those entities by default & have the user make the choice to not do it explicitly? Would the current behavior of the default being false not result in orphan entries (that might potentially become zombie records) that might lead to bloat of

Map autoIncrement non-primary key in hibernate

心已入冬 提交于 2020-08-10 23:11:13
问题 I have a teacher table, where it contains one primary key TEACHER_UNIQUE_ID,and other one autoIncrement key with Index TEACHER_ID. Now i have to map autoIncrement key to other table i.e SUBJECT . I have used below code, but this always sets TEACHER_ID as null in subject class. i want it to insert Subject table with actual autoIncremented TEACHER_ID. public class Teacher { @Id @Column(name = "TEACHER_UNIQUE_ID") private String teacherUniqueId; @GeneratedValue(strategy = GenerationType.AUTO)

JPA Hibernate Dynamic entity mapping & persistence at runtime

浪子不回头ぞ 提交于 2020-08-07 09:49:29
问题 Basically we have a spring boot application that requires that the user can define his/her own set of fields and that these fields should be persisted in their own class/table through JPA/Hibernate at runtime. These classes will be generated dynamically through bytebuddy. All that should be done dynamically without having to restart the application. The Hibernate Dynamic mapping is not an option, since we will be creating new classes entirely and re-map them. I have also considered an EAV

hibernate doesn't update discriminator column when I update with another object

蓝咒 提交于 2020-07-21 04:39:43
问题 I have used a "class per hierarchy strategy" for mapping the following class hierarchy in Hibernate. I have Item as an abstract class. The followings as concrete ones: Book Journal DVD CD My mapping works perfect for saving and loading but it doesn't work correctly on updating an item with a different class. I'm using discriminators for each of the above classes. my item.hbm.xml is like: <!-- language: lang-xml --> <hibernate-mapping> <class name="my.hibernate.items.Item" discriminator-value=

hibernate doesn't update discriminator column when I update with another object

余生颓废 提交于 2020-07-21 04:38:36
问题 I have used a "class per hierarchy strategy" for mapping the following class hierarchy in Hibernate. I have Item as an abstract class. The followings as concrete ones: Book Journal DVD CD My mapping works perfect for saving and loading but it doesn't work correctly on updating an item with a different class. I'm using discriminators for each of the above classes. my item.hbm.xml is like: <!-- language: lang-xml --> <hibernate-mapping> <class name="my.hibernate.items.Item" discriminator-value=

hibernate doesn't update discriminator column when I update with another object

…衆ロ難τιáo~ 提交于 2020-07-21 04:35:07
问题 I have used a "class per hierarchy strategy" for mapping the following class hierarchy in Hibernate. I have Item as an abstract class. The followings as concrete ones: Book Journal DVD CD My mapping works perfect for saving and loading but it doesn't work correctly on updating an item with a different class. I'm using discriminators for each of the above classes. my item.hbm.xml is like: <!-- language: lang-xml --> <hibernate-mapping> <class name="my.hibernate.items.Item" discriminator-value=