@Embeddable and DISTINCT keyword causes duplicate column names in SQL SELECT clause

Posted by John Manko | Posted in Computers & Technology, Java | Posted on 01-07-2011site-map

Using DISTINCT keyword on an Enity classes with an @Embeddable primary-key results in an EclipseLink error. This affects EclipseLink as of 2.2.0.v20110202-r8913. Details after the jump.

Read the rest of this entry »

service

A Case Against JPA

Posted by John Manko | Posted in Java | Posted on 28-09-2009report

Here are some numbers for JPA generated queries verses a custom formatted one:

Based on the following query:

em.createQuery(" SELECT object(o) FROM INTERNALIPADDRESSBINDING o WHERE o.internalIpAddress.ipAddress = :ip AND o.macAddress.macAddress = :mac AND o.bindTimestamp = :bind ")

JPA generated query based on Entity classes and foreign keys:

SELECT t0.ID,
       t0.BINDTIMESTAMP,
       t0.MACADDRESS_MACADDRESS,
       t0.internalIpAddress_ipAddress
FROM   INTERNALIPADDRESSBINDING t0,
       MACADDRESS t2,
       INTERNALIPADDRESS t1
WHERE  ((
         ((t1.IPADDRESS ='4.4.4.4') AND (t2.MACADDRESS = 'ZZ:ZZ:ZZ:ZZ:ZZ:ZZ'))
         AND
         (t0.BINDTIMESTAMP = '2009-09-22 15:01:53.0')
        )
        AND
        (
         (t1.IPADDRESS =t0.internalIpAddress_ipAddress)
         AND
         (t2.MACADDRESS = t0.MACADDRESS_MACADDRESS)
        )
       );

 Empty set (20.53 sec)

My query:

SELECT t0.ID,
       t0.BINDTIMESTAMP,
       t0.MACADDRESS_MACADDRESS,
       t0.INTERNALIPADDRESS_IPADDRESS
FROM   INTERNALIPADDRESSBINDING t0
WHERE  t0.INTERNALIPADDRESS_IPADDRESS = '4.4.4.4'
   AND t0.MACADDRESS_MACADDRESS = 'ZZ:ZZ:ZZ:ZZ:ZZ:ZZ'
   AND t0.BINDTIMESTAMP = '2009-09-22 15:01:53.0';

 Empty set (1.35 sec)
rss
suggest