Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] When does EL compile named-queries?

I have this NamedQuery:
name = "CalendarEntry.getLastActivityEntryForProject"
    , query =
        """SELECT e FROM CalendarEntry e JOIN e.activity.project proj
    WHERE proj.id = :projectId ORDER BY COALESCE(e.changeInfo.modified, e.changeInfo.created) DESC""")
 
For some reason EL generates wrong SQL about 1/2 of the time (the COALESCE-part is messed up, ending with comma instead of parenthese):
 
Query: ReadAllQuery(name="CalendarEntry.getLastActivityEntryForProject" referenceClass=CalendarEntry sql="SELECT t4.entity_id AS a1, t4.type AS a2, t4.VERSION AS a3, t5.entity_id AS a4, t5.adjusted_time AS a5, t5.id AS a6, t5.chargable_time AS a7, t5.description AS a8, t5.duration AS a9, t5.end_date AS a10, t5.end_local_time AS a11, t5.entry_type_id AS a12, t5.has_alerts AS a13, t5.hourly_rate AS a14, t5.internal_note AS a15, t5.all_day_event AS a16, t5.is_chargable AS a17, t5.is_master AS a18, t5.private AS a19, t5.recurring AS a20, t5.location AS a21, t5.occurence_count AS a22, t5.organizer_uri AS a23, t5.priority AS a24, t5.sequence_nr AS a25, t5.start_date AS a26, t5.start_local_time AS a27, t5.status AS a28, t5.title AS a29, t5.uuid AS a30, t5.created AS a31, t5.modified AS a32, t5.modified_by AS a33, t5.created_by AS a34, t5.activity_id AS a35, t5.relation_id AS a36, t5.customer_contact_id AS a37, t5.depends_on AS a38, t5.logged_for AS a39, t5.owner AS a40 FROM onp_crm_activity_log t5, onp_crm_entity t4, onp_crm_activity t3, onp_crm_entity t2, onp_crm_project t1, onp_crm_entity t0 WHERE (((t0.entity_id = ?) AND ((t5.entity_id = t4.entity_id) AND (t4.type = 'CALENDAR_ENTRY'))) AND (((t3.id = t5.activity_id) AND ((t3.entity_id = t2.entity_id) AND (t2.type = 'ACTIVITY'))) AND ((t1.id = t3.project_id) AND ((t1.entity_id = t0.entity_id) AND (t0.type = 'PROJECT'))))) ORDER BY COALESCE(t5.modified,t5.created, DESC LIMIT ? OFFSET ?")
 
Any idea what causes this and how to get around it?
 
Is it possible to tell EL to compile NamedQueries once, upon bootstrapping the PU?
 
Thanks.
 
--
Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc

Back to the top