Hi,
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/Hibern...
Hey all,
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 message:
System.Data.SqlClient.SqlException: Cannot insert explicit value for iden...
Is it possible to navigate through the key-many-to-one associations of a composite-id in Nhibernate?
I have a few (legacy) tables that I mapped with the following settings:
<class name="StructureUser">
<composite-id>
<key-many-to-one name="Structure" class="Structure" column="STRUKTUR_ID" />
<key-many-to-one name="U...
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 CaseAssignm...
Let's say I have an existing database with the following 3 tables:
Table1:
(PK)T1ID1
(PK)T1ID2
Table2:
(PK)T2ID1
Table3:
(FK)T1ID1
(FK)T1ID2
(FK)T2ID1
(Where the 3 keys come from the tables above)
My question is: How do I map Table3 with Fluent NHibernate?
What is confusing to me is what to do about the fact that its composite keys c...
I have a class StoreHours that has a composite key and has been working perfectly. A new demand came up for another type of hours to be returned. I thought "simple, I'll abstract the base class, have two concrete implementations and change my references in the app to one of the new classes". However, upon doing that, my unit tests failed...
I'm using Fluent NHibernate to create an ASP.NET MVC project, with Submissions and Votes (Up/Down) by Users.
Of course, Users can vote submission Up or Down. To record this, I created a middle table, SubmissionVote, which contain the following fields:
submissionId (int)
userId (int)
score (enum: up/down)
Here are my mappings:
Submis...
I have a class in Nhibernate hbm file and for this I'm using a composite id field, in the following way :
<composite-id>
<key-many-to-one name="DContent" class="Business.Entities.DContent, Business" column="DId" />
<key-many-to-one name="Structure" class="Business.Entities.Structure, Business" column="RId"/>
<key-property...
I have a parent object with composite-id (legacy db - can't modify this). I have a child object that is a bidirectional one-to-many (parent-to-children) relationship. The mapping is correct, as I can load an instance of either entity and correctly navigate across the relationship. My problem comes when I store the parent and it cascade...
I am trying to reference some child entities with part of the parents composite key not all of it, why cant I? This happens when I use the following mapping instead of that which is commented.
I get the following error
Foreign key in table
VolatileEventContent must have same
number of columns as referenced
primary key in tabl...
Hi
I am using hibernate3 in my java app to access sqlserver 2008 enterprise.
The hibernate mapping uses composite id and when i try to load model it returns null. I spent days to resolve it but still no result. Composite id mapping should be used for multiple field based PK, but in my table no such PK, i wonder why the JBoss Hibernat...
Environment:
JDK 1.6, JEE5
Hibernate Core 3.3.1.GA, Hibernate Annotations 3.4.0.GA
DB:Informix
Used reverse engineering to create my persistence entities from db schema [NB:This is a schema in work i cannot change]
Getting exception when selecting list of basic_auth_accounts org.hibernate.TypeMismatchException: Provided id of the wrong...
This is probably a simple question to answer but I just can't figure it out.
I have a "Company" class with a many-to-one to "Address" which has a many to one to a composite id in "City". When I load a "Company" it loads the "Address", but if I call any property of "Address" I get the error:
{"could not load an entity: [IDI.Domain.Ent...
I have a situation where I have tables that have many columns used as a composite primary key,
worse off business logic requires these to be mutable.
I am using nhibernate and have no problems mapping for loadig/saving these. However I need to be able to update the property values and have these changes be reflected in the DB when i ...
I have parent/child relationship, and child have composite id
Parent
<id name="Id" type="Int32">
<generator class="identity" />
</id>
<set name="Children" table="CTable" cascade="all-delete-orphan" inverse="true" lazy="false" >
<key column="ParentId"/>
<one-to-many class="ChildrenClass"/>
</set>
Child
<composite...
Hi,
I'm trying to map the following tables/entities in FNH and seem to be getting nowhere fast!
**Tables**
Contacts
ID (PK - int - generated)
...
PhoneTypes
ID (PK - varchar - assigned) (e.g. MOBILE, FAX)
ContactPhones
ContactRefId (PK - FK to Contacts)
PhoneTypeRefId (PK - FK to PhoneTypes)
...
(I should...
Hi, 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
Note: Usually i'd map the AnnouncementsRead using a Many to Many relationship but this table also ha...
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 create...
I have a composite primary key for my object.How can i use a jpa to update my object?
Normally we use the following code
EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa");
EntityManager em = emf.createEntityManager();
Student stud1 = em.find(Student.class,1);
stud1.setSname("Deepak");
//set others
em.merge(stud1)...