composite-id

Hibernate insert failing when embedded key contains identity column on SQL Server

落爺英雄遲暮 提交于 2020-01-14 10:47:42
问题 I'm trying to map an entity with hibernate, but with SQL Server, I am not able to proceed. Following are the details. SQL Server Entity CREATE TABLE [dbo].[BOOK_EMBEDDED]( [row_id] [bigint] IDENTITY(1,1) NOT NULL, [group_no] [int] NOT NULL, [book_name] [varchar](255) NULL, CONSTRAINT [PK_BOOK_EMBEDDED] PRIMARY KEY CLUSTERED ( [group_no] ASC, [row_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON

key-many-to-one and key-property association: nhibernate won't DELETE items from set

耗尽温柔 提交于 2019-12-23 12:19:43
问题 I'll try to keep this terse, but hopefully won't miss any important information in my troubles. The code I believe provides all details, but I've left out the noise (it's VB, so there's lots of noise :) ). A "Case" object has many "Assignments": Public Class Case Property CaseId As Guid Property Assignments As ISet(Of CaseAssignment) End Class Public Class CaseAssignment Property Case As Case Property RoleId As Guid End Class The data model I've been handed looks about like what you'd expect,

NHibernate navigators mapped to the part of a composite key problem - legacy database usage

僤鯓⒐⒋嵵緔 提交于 2019-12-10 14:13:55
问题 We have a legacy database that we cannot change. And we are trying to move to the NHibernate instead of old DataAccess layer which is a garbage and is too slow. it has tables like these: GPI table has (PU_ID, PAR_ID, Data, Data2) columns BLOCK table has (GA_ID, Data, PAR_ID) columns COMPANY table has (PU_ID, Data) columns I had created these mappings for the tables above: GPI <class name="GroupPartnerInterest" table="[GPI]"> <composite-id > <key-property name="GroupId" column="PAR_ID" /> <key

Jpa composite key nullable columns

不想你离开。 提交于 2019-12-10 14:02:03
问题 I'm using Hibernate's JPA impl to model some tables. I'm having trouble mapping a table that: Has no primary key Has a unique index on 4 columns, 3 of which can be nullable I tried to hack it and define the index as a composite Id, but since some columns are nullable this is not working properly. Is this possible with JPA/Hibernate? Thanks 回答1: A work arround is... You should implements your own UserType implementation and treats the null value to return a representative Object for this. Look

Composite Key in JPA / Hibernate with inherited class

不羁岁月 提交于 2019-12-03 10:03:13
问题 i have a composite id defined on my class structure as below. Unfortunatly i always get a hibernate error that complains on the not found "part2": "Property of @IdClass not found in entity MoreClass : part2" Can anybody help me on fixing the problem? (or at least point me on a helpful jpa/hibernate doc?) @IdClass(ClassKey.class) @Entity public class MoreClass extends LessClass implements Serializable { @Id String part1; } @MappedSuperclass public class LessClass implements Serializable { @Id

Composite Key in JPA / Hibernate with inherited class

末鹿安然 提交于 2019-12-03 00:35:44
i have a composite id defined on my class structure as below. Unfortunatly i always get a hibernate error that complains on the not found "part2": "Property of @IdClass not found in entity MoreClass : part2" Can anybody help me on fixing the problem? (or at least point me on a helpful jpa/hibernate doc?) @IdClass(ClassKey.class) @Entity public class MoreClass extends LessClass implements Serializable { @Id String part1; } @MappedSuperclass public class LessClass implements Serializable { @Id String part2; } public class ClassKey implements Serializable { String part1; String part2; } Michael

JPA - Criteria API and EmbeddedId

三世轮回 提交于 2019-11-27 21:08:52
I want to use criteria to make the following query. I have an Entity with EmbeddedId defined: @Entity @Table(name="TB_INTERFASES") public class Interfase implements Serializable { @EmbeddedId private InterfaseId id; } @Embeddable public class InterfaseId implements Serializable { @Column(name="CLASE") private String clase; } And the criteria query that i am trying to do is: CriteriaBuilder criteriaBuilder = this.entityManager.getCriteriaBuilder(); CriteriaQuery<Interfase> criteriaQuery = criteriaBuilder.createQuery(Interfase.class); Root<Interfase> entity = criteriaQuery.from(Interfase.class);

JPA - Criteria API and EmbeddedId

耗尽温柔 提交于 2019-11-26 23:01:00
问题 I want to use criteria to make the following query. I have an Entity with EmbeddedId defined: @Entity @Table(name="TB_INTERFASES") public class Interfase implements Serializable { @EmbeddedId private InterfaseId id; } @Embeddable public class InterfaseId implements Serializable { @Column(name="CLASE") private String clase; } And the criteria query that i am trying to do is: CriteriaBuilder criteriaBuilder = this.entityManager.getCriteriaBuilder(); CriteriaQuery<Interfase> criteriaQuery =