hi I got a serious problem with hibernate right now, for some reason 2 off my classes return wrong queries. The generated sql executed against the database with another tool returns the right result, with hibernate it returns wrong results.
I think the problem might be related to a caching issue, because the first time I run a query it always return the right result, than i execute another query and it mixes the original result with the new result,
Hibernate version: - 3.2.5.ga and 3.0 RC1
Mapping documents:
SampleInfo:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.SampleInfo"
table="`SAMPLE_INFO`"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="`id`"
type="java.lang.Integer"
>
<generator class="native">
<param name="sequence">LINK_ID</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-SampleInfo.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<many-to-one
name="sample"
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.Sample"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="`sample_id`"
/>
<many-to-one
name="metaKey"
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.MetaKey"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="`key_id`"
/>
<property
name="value"
type="java.lang.String"
update="true"
insert="true"
column="`value`"
not-null="true"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-SampleInfo.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
MetaKey
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.MetaKey"
table="`META_KEY`"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="`key_id`"
type="java.lang.Integer"
>
<generator class="native">
<param name="sequence">LINK_ID</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-MetaKey.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="key"
type="java.lang.String"
update="true"
insert="true"
column="`key`"
not-null="true"
/>
<set
name="sampleInfo"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
column="`key_id`"
>
</key>
<one-to-many
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.SampleInfo"
/>
</set>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-MetaKey.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Sample
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.Sample"
table="`SAMPLES`"
dynamic-update="true"
dynamic-insert="true"
>
<id
name="id"
column="`sample_id`"
type="java.lang.Integer"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Sample.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<set
name="bins"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
column="`sample_id`"
>
</key>
<one-to-many
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.bin.Bin"
/>
</set>
<set
name="comments"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
column="type"
>
</key>
<one-to-many
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.SampleComment"
/>
</set>
<many-to-one
name="configuration"
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.Configuration"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="`configuration_id`"
/>
<many-to-one
name="type"
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.Type"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="`type`"
/>
<property
name="correctionFailedString"
type="java.lang.String"
update="false"
insert="false"
column="`correction_failed`"
not-null="true"
/>
<many-to-one
name="experiment"
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.ExperimentClass"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="`class`"
/>
<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="`sample_name`"
not-null="true"
/>
<property
name="newBinAllowedString"
type="java.lang.String"
update="true"
insert="true"
column="`allowNewBin`"
not-null="true"
/>
<set
name="notMatchedSpectra"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
column="`sample_id`"
>
</key>
<one-to-many
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.spectra.NotFoundSpectra"
/>
</set>
<property
name="saturatedString"
type="java.lang.String"
update="false"
insert="false"
column="`saturated`"
not-null="true"
/>
<property
name="setupxId"
type="java.lang.String"
update="true"
insert="false"
column="`setupx_id`"
not-null="true"
/>
<set
name="spectra"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
column="`sample_id`"
>
</key>
<one-to-many
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.spectra.Spectra"
/>
</set>
<property
name="version"
type="java.lang.Integer"
update="false"
insert="false"
column="`version`"
/>
<property
name="visibleString"
type="java.lang.String"
update="false"
insert="false"
column="`visible`"
not-null="true"
/>
<one-to-one
name="result"
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.SampleResult"
cascade="none"
outer-join="auto"
constrained="true"
/>
<set
name="resultLinks"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
column="`sample_id`"
>
</key>
<one-to-many
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.ResultLink"
/>
</set>
<property
name="finishedString"
type="java.lang.String"
update="false"
insert="false"
column="`finished`"
not-null="true"
/>
<property
name="gcMethod"
type="java.lang.String"
update="true"
insert="true"
column="`gcmethod`"
not-null="true"
/>
<property
name="msMethod"
type="java.lang.String"
update="true"
insert="true"
column="`msmethod`"
not-null="true"
/>
<property
name="asMethod"
type="java.lang.String"
update="true"
insert="true"
column="`asmethod`"
not-null="true"
/>
<property
name="qcMethod"
type="java.lang.String"
update="true"
insert="true"
column="`qcmethod`"
not-null="true"
/>
<property
name="dpMethod"
type="java.lang.String"
update="true"
insert="true"
column="`dpmethod`"
not-null="true"
/>
<property
name="operator"
type="java.lang.String"
update="true"
insert="true"
column="`operator`"
not-null="true"
/>
<property
name="tray"
type="java.lang.Integer"
update="true"
insert="true"
column="`tray`"
not-null="true"
/>
<property
name="machine"
type="java.lang.String"
update="true"
insert="true"
column="`machine`"
not-null="true"
/>
<set
name="metaData"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
column="`sample_id`"
>
</key>
<one-to-many
class="edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.SampleInfo"
/>
</set>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Sample.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
What happens between these 3 classes is:
First in a gui I select a sample
-> gui fires event <-
Second in a view I receive the event and the view executes the query
SELECT a FROM SampleInfo a where a.sample.id = 152926
which now fetches the sample info object from the database. The view now renders my objects, this is the execute sql. For each sampleinfo we fetch the metakey object.
Hibernate: select sampleinfo0_."id" as id1_3_, sampleinfo0_."sample_id" as sample2_3_, sampleinfo0_."key_id" as key3_3_, sampleinfo0_."value" as value4_3_ from "SAMPLE_INFO" sampleinfo0_ where sampleinfo0_."sample_id"=152926
Hibernate: select metakey0_."key_id" as key1_10_0_, metakey0_."key" as key2_10_0_ from "META_KEY" metakey0_ where metakey0_."key_id"=?
] Hibernate: select metakey0_."key_id" as key1_10_0_, metakey0_."key" as key2_10_0_ from "META_KEY" metakey0_ where metakey0_."key_id"=?
if i now select another query all datachange except the metakey with the value "GenoType" this value is never updated and I have no idea why.
Code between sessionFactory.openSession() and session.close():
can't provide this code, but is basically the singleton implementation. The error is not related to this part. We validated this
Full stack trace of any exception that occurs:
no exceptions at all
Name and version of the database you are using:
oracle 10g R2
The generated SQL (show_sql=true):
see above
Debug level Hibernate log excerpt:
to much, ask and i can post it, but its a couple of thousand lines
|