Questions tagged [composite-id]

59 questions
37
votes
3 answers

JPA - Criteria API and EmbeddedId

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…
Mauro Monti
  • 1,068
  • 2
  • 12
  • 21
19
votes
2 answers

Composite Key/Id Mapping with NHibernate

I have the following tables in my database: Announcements: - AnnouncementID (PK) - Title AnouncementsRead (composite PK on AnnouncementID and UserID): - AnnouncementID (PK) - UserID (PK) - DateRead Users: - UserID (PK) - UserName Usually I'd map…
7
votes
2 answers

Jpa composite key nullable columns

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…
Miguel Ping
  • 18,082
  • 23
  • 88
  • 136
6
votes
3 answers

Composite Key in JPA / Hibernate with inherited class

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…
6
votes
1 answer

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

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…
5
votes
4 answers

Inserting a record with a Composite Key using NHibernate

I am working with a legacy database that uses composite keys. And I am trying to use NHibernate to insert a new record into the database. NHibernate specifies that I have to create the Id manually, but when I try to insert with this id I get the…
zonkflut
  • 2,929
  • 3
  • 22
  • 25
5
votes
3 answers

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

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] …
himanshu
  • 53
  • 1
  • 4
4
votes
1 answer

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

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…
pettys
  • 2,293
  • 26
  • 38
4
votes
1 answer

NHibernate 3.3: composite-id with a key-property generated?

I have read that this mapping is not possible in NHibernate 3.3:
vladiastudillo
  • 407
  • 1
  • 10
  • 23
3
votes
2 answers

Fluent NHibernate compositeid to mapped class

I'm trying to figure out how to use CompositeId to map another class. Here's a test case: The tables: TestParent: TestParentId (PK) FavoriteColor TestChild: TestParentId (PK) ChildName (PK) Age The classes in C#: public class…
3
votes
0 answers

How to use composite Ids in one-to-many mappings in fluent nhibernate?

I got a scenario where a composite Id uniquely identifies an entity. I defined the MSSQL to have a multiple primary key on those fields. In addition I would like an auto-incremented id to be used for referencing a one-to-many relationship. Here's…
Yuval Kalev
  • 111
  • 6
2
votes
1 answer

NHibernate issues redundant queries with composite keys

For the sake of the example, let's say that I have to model the "person" entity of the database of my country's revenue service, and that in my very small country the first name and the last name of a person are enough to uniquely identify the…
Gabriele Giuseppini
  • 1,541
  • 11
  • 19
2
votes
1 answer

Spring Boot Hibernate JPA mapping composite primary key gives IllegalArgumentException: This class does not define an IdClass

I have configured composite primary key for my entity UserActivity as follows with composite key on msisdn & extReferenceId. Both are annotated with @Id in my entity. The IdClass is UserActivityId and it is annotated too as below. When I start the…
2
votes
0 answers

NHibernate: Use one column for relationship and primary key, Invalid index for this SqlParameterCollection

I've defined a composite-id for my NHibernate database model. I've used one of the columns defined in a foreign key relationship too. If I insert an object using NHibernate, I get the following Exception: System.IndexOutOfRangeException: Invalid…
annemartijn
  • 1,538
  • 1
  • 23
  • 45
2
votes
0 answers

Define generator for composite-id property in NHibernate

I've defined a composite-id for my NHibernate database model. It seems to work, but I cannot set a generator for one key-property. Is it possible to define a generator for a key-propery in a composite-id? C# NHibernate Model public const string…
annemartijn
  • 1,538
  • 1
  • 23
  • 45
1
2 3 4