Hi,

I use Open EJB 3.0 as embedded server to run unit tests, with Hibernate
3.2.6.ga as JPA implementation and HSQLDB as embedded database (memory
mode). It works perfect, much better than others I tried to use until now
(JBoss embedded for example).

Anyway I encounter a problem I can't find how to solve. I created the
following named query in orm.xml file :

        <named-query name="Element.findByFloatData">
            <query><![CDATA[select ev.element from ElementValue ev where
ev.data = :data and ev.floatValue = :floatValue]]></query>
        </named-query>

I have the following method to run this named query:

    public Collection findByFloatData(final Data data, final Float
floatValue)
        throws ElementDaoException
    {
        try
        {
            Query queryObject =
emanager.createNamedQuery("Element.findByFloatData");
            queryObject.setParameter("data", data);
            queryObject.setParameter("floatValue", floatValue);
            List results = queryObject.getResultList();
            return results;
        }
        catch (Exception ex)
        {
            throw new ElementDaoException(ex);
        }
    }

But it nevers returns any result, while I have no problem running the
similar queries with string or int columns instead of float one ! So it's
just a problem with floats. Moreover using Hibernate console, I could make
it work but I had to set my parameter as a double. So it looks like I have a
type mapping problem with floats between Java, JDBC and HSQLDB. For what I
understood this type mapping is configured on the application server. In
JBoss AS (the one I use in production), there's a file for this, called
standardjbosscmp-jdbc.xml. It defines for each database product and each
Java type the JDBC and SQL corresponding types. Do we have the equivalent
with Open EJB ? Or is there something I misunderstood with JPA ? Please tell
me if it's not a problem with Open EJB because I am not sure at all about
this.

Thanks in advance ;)

Olivier

Reply via email to