About TypedQuery

forum_thread

Subquery error

My query: TypedQuery<Station> query = em.createQuery("SELECT p FROM Station p WHERE rid = (SELECT p FROM Station p where tpl='York') AND tpl != 'York'", Station.class);   Error: ... My query: TypedQuery<Station> query = em. createQuery ( "SELECT p ...

 
forum_thread

Sorting problem

Hi, I was rewriting our DAO to support pagging in large dataset and I think I have found a problem with sorting. I send you a test case - sorry for using the same project as previous, but it was faster to write this test case. As usual, you can load data with DataLoader and then check problem with QueryData. There is a simple query with "order by" sentence: ... List<Branch> prodList = null ; TypedQuery<Branch> icQuery = null ; String q = null ...

 
forum_thread

Query perfromance problem

Hi, I was playing with paging and sorting recently and after trying few different aproaches got some strange behavior from ODB. First of all, I will show you results from page rendering times, but trust me - when debugging application, getting data from ODB takes a long time in one case. Anyway, one of my methods in DAO looks like this: ... ; List<Product> prodList = null ; TypedQuery<Product> icQuery = null ; if ( ...

 
forum_thread

Finding an object by its datetime

SearchBookingByTimeStamp() { Calendar btime = Calendar.getInstance(); btime.set(2012, 10, 11, 7, 30, 00); //This time is already inserted, trying to find it /* My Query */ TypedQuery<Booking> query = em.createQuery( "SELECT b FROM Booking b WHERE b.btime = :btime", Booking.class) .setParameter("btime", btime, TemporalType.TIMESTAMP); } @Entity public class Booking { @Temporal(TemporalType.TIMESTAMP) Calendar btime; }   ... trying to find it   /* My Query */ TypedQuery<Booking> query = em. createQuery ( ...

 
forum_thread

Is there any faster select method?

SELECT: TypedQuery<Point> query = em.createQuery("SELECT p FROM Point p WHERE p.id = " + element.getId(), Point.class); List<Point> points = query.getResultList();   WRITE: em.persist(p);   ** the Point class is of the tutorial.   I found the above select method is ten times slower than the write method, in my very simple benchmark. I guess the reason there is no SQL in the write method.   ... 04:40 SELECT: TypedQuery<Point> query = em. createQuery ( "SELECT p ...

 
forum_thread

java.lang.ClassCastException in query results

I have a simple object stored in a ObjectDb file Stadium Name (java.lang.String) Capacity (int) City (java.lang.String)   When i run the following code i get the ClassCastException in the "for (Stadium result : results)" line ... in the "for (Stadium result : results)" line TypedQuery<Stadium> query = em. createQuery ( "SELECT ...

 
forum_thread

Extra uninitialised entities spawned on merge()

In the following, Element is a base entity class, with a bi-directional @ManyToOne-@OneToMany relationship Element owner - List<Element> ownedElements, and Example is a subclass entity with a relationship @OneToOne Element child. ... ) . commit ( ) ;   TypedQuery<Element> query = em. createQuery ( "SELECT e ...

 
forum_thread

JPA - ExceptionInInitializerError when creating EntityManager

EntityFactoryManager(emf) is successfully received but error at emf.createEntityManager Please see my code of fragment from my project. public class Main {        final private static Properties EMAIL_PROPS;      final private static String EMAIL_FROM;            static {  EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("tmpCLMSPU"); ... = emf. createEntityManager ( ) ; TypedQuery<EmailSettings> emailSettings = emTemp. createNamedQuery ...

 
forum_thread

How to creat a Query with Sql which returns a List<Mark> marks

How can i get out of the db my Athlete Objekt his list<Mark> marks collection with a createQuery Sql-Statement. the Mark and Athlete Object do not really have a primary or secondary key together, the list mark is just stored in the athletes object, not as an embeddable but as an entity. ... = new DBConnection ( ) ; TypedQuery<Mark> query = dbConnection. getEm ( ) . ...

 
forum_thread

Error: Failed to write value of field X using reflection (oneToMany relation)

Hi there! I have been all day trying to solve this. I have read multiple sites and documentation, but I can go through this. I have a clase named Pedido, that have a reference ManyToOne to a clase Cliente. ... results = null ; try { TypedQuery<Cliente> query = em. createQuery ( "SELECT c ...