So I'm trying to do a query using a long, and i continue to get the same exception (see below).
workaround i've tried:
-adding the sql-type to the mapping file
-changing the column in mysql to 'long'
-using java.lang.Long instead of 'long'
-changed my long to an int
is this a bug? or am i doing something wrong?
thanks-
sara
Hibernate version:
hibernate 3 beta 4 with new AST parser
Mapping documents:
Code:
<class name="Reference" table="Reference">
<id name="id" column="ref_id" type="integer">
<generator class="increment"/>
</id>
<property name="authors" column="authors" type="string" />
<property name="title" column="title" type="string" />
<property name="year" column="year" type="int" />
<property name="url" column="URL" type="string" />
<property name="comment" column="comment" type="string" />
<!--set name="evidences" lazy="true" table="Reference2Evidence">
<key column="referenceId"/>
<many-to-many
class="ca.mcgill.mcb.bias.hibernate.common.Evidence"
column="evidenceId" />
</set-->
<set name="techniques" table="Reference2Technique" inverse="false"
lazy="true">
<key column="referenceId"/>
<many-to-many class="ca.mcgill.mcb.bias.hibernate.common.Technique"
column="techniqueId"/>
</set>
<joined-subclass name="LiteratureReference" table="LiteratureReference">
<key column="ref_id"/>
<property name="pubmed" type="long">
<column name="pubmed_id" sql-type="bigint"/>
</property>
<property name="doi" column="doi" type="string"/>
<property name="journal" column="journal" type="string"/>
<property name="volume" column="volume" type="string"/>
<property name="pages" column="pages" type="string"/>
<property name="issue" column="issue" type="string"/>
</joined-subclass>
<joined-subclass name="BookReference" table="BookReference">
<key column="ref_id"/>
<property name="publisher" column="publisher" type="string"/>
<property name="publisher_location" column="publisher_location"
type="string"/>
<property name="isbn" column="isbn" type="string"/>
<property name="page_no" column="page_no" type="int"/>
</joined-subclass>
</class>
Code between sessionFactory.openSession() and session.close():Code:
public static List<LiteratureReference> getRefByPubMed(Session session, long pubmed) throws HibernateException
{
List<LiteratureReference> refs=new ArrayList();
Query q=session.createQuery("select distinct litref from LiteratureReference where litref.pubmed=?");
q.setEntity(0,new Long(pubmed));
refs=q.list();
return refs;
}
Full stack trace of any exception that occurs:
36380 ERROR PSIMLParser - unexpected result from database while checking for Literature reference 9111019
org.hibernate.MappingException: Unknown entity: java.lang.Long
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:484)
at org.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:574)
at org.hibernate.type.ManyToOneType.getReferencedType(ManyToOneType.java:26)
at org.hibernate.type.ManyToOneType.getColumnSpan(ManyToOneType.java:34)
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:115)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:70)
at ca.mcgill.mcb.bias.hibernate.parsers.EvidenceTools.getRefByPubMed(EvidenceTools.java:77)
at ca.mcgill.mcb.bias.hibernate.parsers.PSIMLParser$ExperimentDesc.createReference(PSIMLParser.java:522)
at ca.mcgill.mcb.bias.hibernate.parsers.PSIMLParser$ExperimentDesc.createEvidence(PSIMLParser.java:571)
at ca.mcgill.mcb.bias.hibernate.parsers.PSIMLParser$ExperimentDesc.access$1300(PSIMLParser.java:482)
at ca.mcgill.mcb.bias.hibernate.parsers.PSIMLParser.createEvidenceSet(PSIMLParser.java:1545)
at ca.mcgill.mcb.bias.hibernate.parsers.PSIMLParser$Interaction.createTuple(PSIMLParser.java:1091)
at ca.mcgill.mcb.bias.hibernate.parsers.PSIMLParser.addInteraction(PSIMLParser.java:1508)
at ca.mcgill.mcb.bias.hibernate.parsers.PSIMLParser.loadEntry(PSIMLParser.java:1483)
at ca.mcgill.mcb.bias.hibernate.parsers.PSIMLParser.main(PSIMLParser.java:161)
Name and version of the database you are using:
Mysql 4.1.3
The generated SQL (show_sql=true):
can't generat eit
Debug level Hibernate log excerpt:
not sure what is relavant here....i can't seem to find the query itself.. all ihave is the stack trace.