ejbql

Hibernate (JPA) how to do an eager query, loading all child objects

Relating to my earlier question, I want to ensure all the child objects are loaded as I have a multiple threads that may need to access the data (and thus avoid lazy loading exceptions). I understand the way to do this is to use the "fetch" keyword in the query (EJB QL). Like this: select distinct o from Order o left join fetch o.orde...

Problem with "not (a, b) in (select ...)" in JPA query using Hibernate EntityManager

Observation: This is a repost of a question I asked at the Hibernate forum but got no response. I have a simple graph structure like this (in MySQL): create table Node( id int not null auto_increment, name varchar(255), primary key(id) ) engine=InnoDB; create table Edge( source int not null, target int not null, cost...

EJBQL select new clause, and constructor parameter representing a collection

I'm doing some werid reporting from JPA datastore. I need to select (using EJBQL) list of objects and these objects contain collection of entities ie I have class that is constructed by: FOOBean(String param1, String param2, List<Entity> listParam) (notice that third parapeter is a list) And I want to select list of thes...

Select nvl(max(c.EmployeeId),0) in JPQL?

I'm using oracle10g database and eclipselink, I need to obtain the last inserted key from the table so i've created this query javax.persistence.Query q = em.createQuery("SELECT nvl(MAX(c.myAtt),0) " + "from myTable as c"); return Integer.parseInt(q.getSingleResult().toS...

SEAM ENTITYQUERY - Problems with Restriction seam-gem example

My project was originally generated by seam-gen and the action "List" bean is not working as i expected. The restriction array has all the attributes from table and is behaving as if all the parameter were mandatory. See the List Bellow: package br.com.autenticis.comvenif_red_web.session; import br.com.autenticis.comvenif_red_web.entit...

Using rownum in EJBQL for Pagination CMP 2.1

I need to implement Pagintion of CMP2.1 Entity Beans. Is it possible to do it using EJB-QL ? Am using weblogic10.3 + Oracle DB. I was planning to use "rownum >= min_row_size + PreparedQUery.setMaxResult()" to get desired result . But rownum in EJB-QL is not recognized by weblogic . Is there any way to specify psuedo column in EJb-QL ? ...

Data structure to hold HQL or EJB QL

We need to produce a fairly complex dynamic query builder for retrieving reports on the fly. We're scratching our heads a little on what sort of data structure would be best. It's really nothing more than holding a list of selectParts, a list of fromParts, a list of where criteria, order by, group by, that sort of thing, for persistence...

Is it possible to test a JPA/EJB QL statement with regex?

I'm not an expert on regular expressions so I thought I'd throw this question out. I'm thinking regular expressions can help make my tests more robust (testing generated EJB QL statements for correct generation). For example: select u.firstName, u.lastName from Users u where u.age > 50 What regex do I use to split it into the followin...

Querying record by date (01 may 1916) on Oracle using Java/EJB 2.x

I have an EJB 2.1 entity bean that queries a "date of birth" column in an Oracle table. The column in the database is of type DATE. The query works without problems except for one specific date: 01 may 1916. This has something to do with daylight savings. Oracle stores the date as: 5/1/1916 1:00:00 AM, while the time of all other dates...

EJB-QL Query List inside Object

I'm attempting to write what should be a simple (I hope) EJB-QL query. Here are my objects: public class Room { private String name; private List<RoomConfiguration> configs; } public class RoomConfiguration { private Integer capacity; private String name; } How can I search for rooms with a minimum capacity? A r...

Could I order in EJBQL by a function which is not mapped to a column in database?

Hello everyone, I would like to order a query by a function which uses properties of the class. Something like: @entity class A { private int id; private String name; public int StringLength() { return name.length(); } } And the sentence something like: "select n from A order by name.StringLength()". Is it possible? Thanks in advan...

What is the correct syntax for an ejbql query that traverses four levels of many to one relationships

I have a simple data model in JPA (hibernate) consisting of many to one and one to one relationships similar to this: town -> state -> governor -> nation -> continent where town is many to one to state, state is one to one to governor, governor is many to one to nation and nation is many to one to continent. I would like to fetch a si...

Converting Oracle date arithmetic to work in HSQLDB

I'm trying to spot-test an Oracle backed database with hsqldb and dbunit, but I've run into a snag. The problem is with the following EJB-QL (simplified a bit): SELECT o FROM Offer o WHERE :nowTime BETWEEN o.startDate AND o.startDate + 7 This seems to only work in Oracle's version of SQL. What's the easiest way for me to conver...

EJBQL date comparison

Hi; In EJBQL how can compare two date values; suppose "Select e from Employee e where e.start_date > :start_date" If I set query parameter with setParameter("start_date", new Date()); An Exception occurs on running.. I wait for your suggestions ...

Does an EJB-QL UPDATE statement defeat CMP...

Does running an EJBQL UPDATE statement defeat the performance benefits of container managed persistance when compared to modifing the accessors on a managed entity? I'm interested in this specifically for a database load / performance perspective. For example, if I have an entity called MyEntity and I want to update myField1 and myFiel...

How do I use a EJBQL between query with two identical dates?

I have a JPA named query that takes two dates in order to return records with a date column entry between the two dates. If I enter the same date for both the start and end dates it returns no rows, even though there are records for that date. Is there way to make the query work or shall I just run another query when the two dates are ...

List of list of named parameters in EJBQL/HQL

I'm trying to execute a long 'INSERT ON DUPLICATE KEY UPDATE' with up to a few thousand rows in a MySQL+JBoss+Hibernate application. It looks something like: INSERT INTO Table (field1, field2, field3) VALUES (value1_1, value2_1, value3_1), (value1_2, value2_2, value3_2), (value1_3, value2_3, value3_3), ... ON DUPLICATE KEY UPDATE ... ...

EJB-QL query never returning unless another query is run

I have a strange strange problem. When executing the following EJB-QL query, my ENTIRE application will stop responding to requests, as the query never finishes executing. Query q = em.createQuery("SELECT o from RoomReservation as o WHERE o.deleted = FALSE AND o.room.id IN (Select r.id from Room as r where r.deleted = FALSE AND r.typ...

Is this valid EJB-QL?

I have the following construct in EJB-QL several EJB 2.1 finder methods: SELECT distinct OBJECT(rd) FROM RequestDetail rd, DetailResponse dr WHERE dr.updateReqResponseParentID is not null and dr.updateReqResponseParentID = ?1 and rd.requestDetailID = dr.requestDetailID and rd.deleted is null and dr.deleted is ...

Rename the fields of ejbql query in ireport

Hi, im using iReport 3.7.3 with ejbql connection my problem is when i want get the fields from the query, the ireport sets the name of the fields with "COLUMN_1", "COLUMN_2" even if i use the sentence "as" the ireport get's me that name to the fields. Here's an example of my query select doc.docId as DocumentID, doc.transactionDate as T...