Scientific name is actually Taxa now...
The query
Code:
from Taxa where taxon=? and lower(name) like lower(?) and recordId>=? order by recordId
The Taxa mapping
Code:
<hibernate-mapping>
<class name="org.gbif.col2005.model.Taxa" table="taxa">
<id name="recordId" column="record_id" type="long">
<generator class="native">
</generator>
</id>
<property name="taxon" type="java.lang.String" update="true" insert="true"
column="taxon"/>
<property name="name" type="java.lang.String" update="true" insert="true"
column="name"/>
<property name="nameCode" type="java.lang.String" update="true"
insert="true" column="name_code"/>
<set name="commonNames" lazy="false">
<key column="name_code" property-ref="nameCode"/>
<one-to-many class="org.gbif.col2005.model.CommonName"/>
</set>
</class>
</hibernate-mapping>
The common name mapping (The composite key was just because I was playing with another idea)
Code:
<hibernate-mapping>
<class name="org.gbif.col2005.model.CommonName" table="common_names">
<composite-id name="key" class="org.gbif.col2005.model.CompositeKey">
<key-property name="recordId" type="long" column="record_id"/>
<key-property name="nameCode" type="java.lang.String"
column="name_code"/>
</composite-id>
<property name="commonName" type="java.lang.String" update="true"
insert="true" column="common_name"/>
<property name="country" type="java.lang.String" update="true" insert="true"
column="country"/>
<property name="language" type="java.lang.String" update="true"
insert="true" column="language"/>
</class>
</hibernate-mapping>
This all works for when there is a name_code in the Taxa, but when that is an empty String (legacy DB that can't be changed), there are no common names for this scenario, but that's when I get the exception trace above.
There should be no results to be associated without a session anyways.
Thanks for looking