Code:
PERSON Class:
===========
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name="version"
)
@DiscriminatorFormula("case when version=(select max(p.version) from supervisory_owner.gss_person p where p.prism_id = prism_id) then '1' else '0' end")
@DiscriminatorValue("0")
public class PersonImpl implements Person { }
LatestPerson Subclass of PersonImpl
===========================
@Entity
@DiscriminatorValue("1")
public class LatestPerson extends PersonImpl {
private static final long serialVersionUID = -5859833321414460749L;
/**
* The person's prism id.
*/
@BeanProperty
@javax.persistence.Column(
name="prism_id", insertable=false, updatable=false
)
private Integer prismId;
public Integer getPrismId() {
return prismId;
}
public void setPrismId(Integer prismId) {
this.prismId = prismId;
}
}
Manager Class:
===========
public class PersonManagerImpl extends HibernatePersistenceManager<Person>
implements PersonManager {
public Person byEmailAddress(String emailAddress, Long version)
throws PersistenceException {
Person test = null;
DetachedCriteria criteria = getExampleCriteria();
criteria.add(Restrictions.eq("version.identifier", version));
criteria.add(Restrictions.eq("emailAddress", emailAddress));
test = unique(queryByCriteria(criteria));
return test;
/*Person testPerson = null;
String query = "from PersonImpl p where p.emailAddress = :email and p.version = :version";
Session session = getSessionFactory().openSession();
session.beginTransaction();
Query q = session.createQuery(query);
q.setString("email", emailAddress);
q.setLong("version", version);
testPerson = (Person)q.uniqueResult();
session.close();
return testPerson;*/
}
}
1).If i use the person manager to get person object by email address by using criteria its working for all the persons,,,
except only for one person email.. . The person name has special character '.
Note:
-----
Becuase of the descriminator LatestPerson class is get loaded....for all persons it is loading correctly...
but only for that particular person its not loading....
2).but if i use HQL no probelem at all it working also for all persons.....
3).I just try to get person by email in test jsp ... Here also working with out problem