Hi all, I am having a problem with a simple query. I want to retreive all the region of my database. When I run the sql generated it works fine. When I read the list that hibernate gives me, it has some elements twice in the list. Anyone has any idea about what is happening?
Hibernate version:
2.1.7
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping >
<class name="com.roche.dss.extreportdomainmodel.RegionDropDown" table="REGIONS_LU">
<composite-id>
<key-property name="regionCode" column="REGION_CODE"/>
<key-property name="countryCode" column="COUNTRY_CODE"/>
</composite-id>
<property name="description"
type="string"
column="DESCRIPTION"
length="50"/>
<property name="activeFlag"
type="string"
column="ACTIVE_FLAG"
length="1"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public List getRegionList() {
Session session = HibernateUtil.getSession();
List regionList = null;
try {
regionList = session
.find("from RegionDropDown region where region.activeFlag = 'Y' order by region.description");
} catch (HibernateException e) {
throw new DataAccessException(e);
}
return regionList;
}
Name and version of the database you are using:
oracle9i
The generated SQL (show_sql=true):
Hibernate: select regiondrop0_.REGION_CODE as REGION_C1_, regiondrop0_.COUNTRY_CODE as COUNTRY_2_, regiondrop0_.DESCRIPTION as DESCRIPT3_, regiondrop0_.AC
TIVE_FLAG as ACTIVE_F4_ from REGIONS_LU regiondrop0_ where (regiondrop0_.ACTIVE_FLAG='Y' ) order by regiondrop0_.DESCRIPTION
|