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)?
|