Eric
Eric

Reputation: 303

org.hibernate.MappingException: Unknown entity: java.lang.Double

I want to select records from db by matching a Double value.

The code is as below:

String aQuery = "SELECT * FROM TableA WHERE field_a = :fieldA";

SQLQuery thisQuery = session.createSQLQuery(aQuery).addEntity(AClass.class);
thisQuery.setEntity("fieldA", aDoubleValue);

a.hbm.xml

<class name="AClass" table="a_table">
    <id name="id" column="id" type="pguuid" access="field">
        <generator class="identity" />
    </id>

    <property name="fieldA" column="field_a"type="double" />
    ....
</class>

Then got this issue org.hibernate.MappingException: Unknown entity: java.lang.Double

Any idea on how to fix it?

Upvotes: 0

Views: 223

Answers (1)

fabiojb
fabiojb

Reputation: 331

Aren't you supposed to use setParameter instead of setEntity?

thisQuery.setParameter("fieldA", aDoubleValue);

Upvotes: 5

Related Questions