-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Unknown entity: java.lang.Long
PostPosted: Mon Feb 21, 2005 3:22 pm 
Newbie

Joined: Mon Dec 13, 2004 5:56 pm
Posts: 12
Location: Montreal, QC
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 4:53 pm 
Newbie

Joined: Tue Aug 02, 2005 2:34 pm
Posts: 2
I know this is from a while back, but just in case someone is checking the archives....

Your problem is that in the getRefByPubMed method, you're using

Code:
q.setEntity(0,new Long(pubmed));


You should be using

Code:
q.setParameter(0,new Long(pubmed));


setEntity should be used for references to other Hibernate-mapped objects. For the primitive long, you can use 'setLong'. For the WRAPPED primitive Long, you use setParameter.

Hope this helps.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.