Hi,
I have a schema that look like this
Code:
create table terminal (
terminalid integer not null,
constraint PK_terminal primary key (terminalid)
);
create table plantype (
terminalid integer not null,
plan_lid integer not null,
plan_sid integer not null,
constraint PK_plantype primary key (terminalid, plan_lid, plan_sid),
constraint FK_plantype_terminal foreign key (terminalid) references terminal(terminalid)
);
create table profile(
terminalid integer not null,
profile_lid integer not null,
profile_sid integer not null,
plan_lid integer,
plan_sid integer,
constraint PK_profile primary key (terminalid, profile_lid, profile_sid),
constraint FK_profile_terminal foreign key (terminalid) references terminal(terminalid),
constraint FK_profile_plantype foreign key (terminalid, plan_lid, plan_sid) references plantype(terminalid, plan_lid, plan_sid)
);
middlegen generates the following:
Code:
<class
name="data.model.Profile"
table="profile"
>
<composite-id name="comp_id" class="data.model.ProfilePK">
<key-property
name="terminalid"
column="TERMINALID"
type="java.lang.Integer"
length="10"
/>
<key-property
name="profileLid"
column="PROFILE_LID"
type="java.lang.Integer"
length="10"
/>
<key-property
name="profileSid"
column="PROFILE_SID"
type="java.lang.Short"
length="5"
/>
</composite-id>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- uni-directional many-to-one association to Terminal -->
<many-to-one
name="terminal"
class="data.model.Terminal"
update="false"
insert="false"
>
<column name="TERMINALID" />
</many-to-one>
<!-- end of derived association(s) -->
<!-- uni-directional many-to-one association to DotPlanType -->
<many-to-one
name="planType"
class="data.model.planType"
>
<column name="TERMINALID" />
<column name="PLAN_TYPE_SID" />
<column name="PLAN_TYPE_LID" />
</many-to-one>
</class>
I'm having problems getting searches to work properly. I tried:
Code:
Profile getProfile(Profile profile) {
Example example = Example.create(profile);
return session.createCriteria(Profile.class).add(example).list();
}
This will cause an exception if the PLAN_TYPE_LID and the PLAN_TYPE_SID columns are empty. I get an exception that looks like this:
Code:
No row with the given identifier exists: net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: data.model.PlanTypePK@18f7386[terminalid=9999,planTypeLid=<null>,planTypeSid=<null>], of class: data.model.DotPlanType
.
.
.
Is it possible to do searches (with out building a complete HQL query manually) by specifying an object and have Hibernate ignore everything that is null, even foreign composite id's?
Thanks,
L