Questions tagged [ejbql]

EJB QL is a Query Language provided for navigation across a network of enterprise beans and dependent objects defined by means of container managed persistence.

EJB QL is a Query Language provided for navigation across a network of enterprise beans and dependent objects defined by means of container managed persistence. EJB QL is introduced in the EJB 2.0 specification. The EJB QL query language defines finder methods for entity beans with container managed persistenceand is portable across containers and persistence managers. EJB QL is used for queries of two types of finder methods:

  1. Finder methods that are defined in the home interface of an entity bean and which return entity objects.
  2. Select methods, which are not exposed to the client, but which are used by the Bean Provider to select persistent values that are maintained by the Persistence Manager or to select entity objects that are related to the entity bean on which the query is defined. From the EJB
52 questions
20
votes
7 answers

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…
Chris Kimpton
  • 5,358
  • 6
  • 43
  • 71
10
votes
1 answer

Hibernate: Can't use a named parameter for OFFSET and LIMIT?

I'm trying to get the following NamedQuery to work: @NamedQuery(name="MyEntity.findByUser", query="SELECT m FROM MyEntity m WHERE m.owner = :user OFFSET :offset LIMIT :limit") The problem is that this causes Hibernate to explode with the following…
aroth
  • 51,522
  • 20
  • 132
  • 168
4
votes
4 answers

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) " + …
J. Bend
  • 181
  • 2
  • 2
  • 13
3
votes
3 answers

How can I cast a Integer to a String in EJBQL

I got a Entity with a Integer @Entity(name=customer) public Customer { ... @Column private int number; ... //getter,setter } Now I want to cast this Integer in a query to compare it with an other value. I tried this…
Paul Wasilewski
  • 7,810
  • 4
  • 38
  • 49
3
votes
1 answer

How to select the sum of multiple count() selections in JPQL

What's the equivalent JQPL statement of the following SQL statement: SELECT (SELECT COUNT(*) FROM foo) + (SELECT COUNT(*) FROM bar)
user953217
  • 231
  • 1
  • 10
2
votes
1 answer

JPQL: determine sub class type from super class join?

My question is very similar to this one: How can I write a Hibernate Criteria query, for a super-class, and check for a certain sub-class? ..., except for one thing: I'm using a JPQL query instead of the Hibernate Criteria API (still Hibernate as a…
Kawu
  • 12,601
  • 31
  • 109
  • 189
2
votes
1 answer

EJB-QL in Expression Language using Seam: Finding more than one value

I'm trying to come up with an Expression that will find two values within a column. I'm using JBoss 4.2.2, JSF 1.2, RichFaces 3.3. In these two single examples: "personData.status in (#{personSortDataList.statusChoice == 'A' ? " +…
mikjall77
  • 51
  • 2
2
votes
6 answers

Toplink bug. Empty result for valid sql with not empty result

How is it possible? We are executing EJBQL on Toplink(DB is Oracle) and query.getResultList is empty. But! When i switched log level to FINE and received Sql query, that TopLink generates, i tried to execute this query on database and (miracle!) i…
Sergey Vedernikov
  • 7,163
  • 2
  • 23
  • 27
2
votes
2 answers

EJBQL/MySQL Regexes and IN

I have a list of Regexes and want to return those rows with a field which passes any regex. Is there anyway to something like the following: SELECT * FROM Foo as f WHERE f.bar IN ("regex1","regex2"); It doesn't look like Regexes are possible at all…
Jim
  • 21,521
  • 5
  • 49
  • 80
2
votes
2 answers

case-insensitive search in EJB QL

This looks really simple and I can't believe I haven't found a solution myself. I have a bean named PersonBean, which has a name. Now I want to write a finder method that takes a string and looks for people with that string in their name,…
phunehehe
  • 8,078
  • 7
  • 43
  • 77
2
votes
3 answers

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 …
Yishai
  • 84,976
  • 26
  • 176
  • 250
2
votes
1 answer

Is there any substitute for ifnull()

I have a query for mysql where ifnull() is used.i want to convert it into ejb-ql. Problem here is that i dont find any substitute equivalent to ifnull() in ejb. For eg: ifnull(columnname,' ') as newcoulmn
Mufaddal Kagda
  • 140
  • 1
  • 10
2
votes
3 answers

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…
Jon Bristow
  • 1,590
  • 2
  • 24
  • 40
2
votes
1 answer

Passing two parameters to a named query

I have the following namedquery over my entity "Intervention ": @NamedQuery(name = "Intervention.findNextMission", query = " SELECT i FROM Intervention i WHERE i.heureDebut> :DateToBeSpecified and i.idAgent= :idAgent")` i dont know how to…
mounaim
  • 155
  • 1
  • 3
  • 8
1
vote
1 answer

How to set parameters within '' in EJB query

In EJB query, it's recommended to use setParameters() instead of concatenating string parameters in order to avoid SQL injection attack. My question is: how to set parameters within '' in SQL update statements with 'SET': String basicQuery = "update…
Wangge
  • 462
  • 1
  • 4
  • 9
1
2 3 4