-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Table with no precise Primary Key Columns
PostPosted: Mon Mar 15, 2010 6:42 am 
Newbie

Joined: Mon Mar 15, 2010 6:17 am
Posts: 2
I have an audit log table for maintaing history information related to the application with the foll. columns in Oracle.

LOOKUP_TYPE VARCHAR2(40) NOT NULL,
MODIFIED_BY VARCHAR2(30) NOT NULL,
MODIFIED_DATE DATE NOT NULL,
OLD_NAME VARCHAR2(100),
NEW_NAME VARCHAR2(100),
OLD_VALUE VARCHAR2(100),
NEW_VALUE VARCHAR2(100)

There is no precise primary key here. Functionally LOOKUP, MODIFIED_BY, MODIFIED_DATE and 2 of the foll. columns (OLD_NAME, NEW_NAME, OLD_VALUE, NEW_VALUE) make up the primary key.

The foll. returns the list of records matching the LOOKUP_TYPE. Even though the number of records returned is correct, but all them are duplicates of the first record.

Session session = HibernateUtil.getSession();
Criteria criteria = session.createCriteria(LookupAuditTrail.class);
criteria.add(Restrictions.eq("lookupType", lookupType));
return criteria.list();

Is a precise primary/composite key required for Hibernate to perform database operations(query/insert)?


Top
 Profile  
 
 Post subject: Re: Table with no precise Primary Key Columns
PostPosted: Mon Mar 15, 2010 6:56 am 
Newbie

Joined: Mon Mar 15, 2010 6:17 am
Posts: 2
I was wondering if the CompositeUserType implementation for the primary key help here?

I could include all the columns of the table in the primary key.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.