Query - Hibernate to JPA/TopLink Conversion

Hi,
I have some problems with a query. My query works fine in Hibernate but I have to work with TopLink.
I have created the query below.
int Language = 1;
String hql = "SELECT DISTINCT g "
+    "FROM GUI g "
+    "JOIN FETCH g.gUINameAllocation gna "
+    "JOIN FETCH g.elementAllocation gea "
+    "JOIN FETCH gea.elementTextAllocation geta "
+    "WHERE g.gUIID = " + java.lang.Integer.toString(GUI) + " "
+    "AND gna.languageAllocation.languageID = " + java.lang.Integer.toString(Language)
+    "AND geta.languageAllocation.languageID = " + java.lang.Integer.toString(Language);
Query query = session.createQuery(hql);
java.util.List<GUI> results = (java.util.List<GUI>)query.list();
I have tried to translate the query to JPQL but it does not allow alias names for fetch joins. I have tried to translate it to the Criteria API classes but I will not work. I have tried the Criteria API with the join class and the fetch class.
I can not use the fetch class in crit.where(...) expression. I can only use there the join classes as far as I understood.
int Language = 1;
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<GUI> crit = cb.createQuery(GUI.class);
crit.distinct(true);
Root<GUI> c = crit.from(GUI.class);
Join<GUI, GUIName> guiname = c.join("gUINameAllocation", JoinType.LEFT);
Join<GUIName, Language> language = guiname.join("languageAllocation");
Join<GUI, Element> guielement = c.join("elementAllocation", JoinType.LEFT);
Join<Element, ElementText> guielementtext = guielement.join("elementTextAllocation", JoinType.LEFT);
Join<ElementText, Language> language1 = guielementtext.join("languageAllocation");
crit.where(cb.equal(language.get("languageID"), Language));
crit.where(cb.equal(language1.get("languageID"), Language));
Has somebody an idea for a solution?
Thx in advance

JPA does not allow alias names on fetch joins, I suspect partially because they could then be used in the filtering in the query - which is exactly what you are doing. This could cause potential caching issues, as the entity that is built might end up missing references that don't conform to the conditions in the where clause, as discussed here:
http://www.coderanch.com/t/486454/ORM/databases/Join-Fetch-EclipseLink
According to bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=293775 this has been changed and is supported in EclipseLink 2.4 to some degree.
If you cannot use EclipseLink 2.4 or later, the way to do this in JPQL is to use a separate join for the alias to be used in the query, and one for the fetch join.
"SELECT DISTINCT g FROM GUI g "
+ "JOIN FETCH g.gUINameAllocation "
+ "JOIN FETCH g.elementAllocation "
+ "JOIN g.gUINameAllocation gna "
+ "JOIN g.elementAllocation gea "
+ "JOIN gea.elementTextAllocation geta "
+ "WHERE g.gUIID = " + java.lang.Integer.toString(GUI) + " "
+ "AND gna.languageAllocation.languageID = " + java.lang.Integer.toString(Language)
+ "AND geta.languageAllocation.languageID = " + java.lang.Integer.toString(Language);
Unfortunately JPA does not allow nested fetch joins, so the only way to fecth gea.elementTextAllocation is through a query hint:
query.setHint("eclipselink.join-fetch", "g.elementAllocation.elementTextAllocation");
EclipseLink/TopLink's join-fetch query hint is described here:
http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Query_Hints#Join_Fetch
Best Regards,
Chris

Similar Messages

  • JPA/Toplink changes the query logic

    Hi,
    Iam currently using JPA with Toplink implementation , i guess that toplink has its own way of optimizing the provided JPA query ; on another words , toplink sometimes changes the way you are using joins and exists statement to what looks optimized , but unfor. this caused me troubles tracking a query that should work on a certain way but its not cause the generated query by Toplink ( can be captured on the log ) does not represent the same logic , is this a known issue or do i have to write my JPA query on a way on which can be translated correctly by toplink , i know i should provide the query it self , but the model structure is too complex.
    Thanks in advance

    Hello,
    JPQL does not directly translate to SQL, so there might be some differences in what you may be expecting due to JPA requirements on the results that are returned. If there is a problem with specific queries, please let us know and file a bug if it is not behaving the way it should. A workaround would be to use a native SQL query directly.
    Best Regards,
    Chris

  • Hibernate/IBatis/JPA for batch applications

    We are planning on developing a batch application. Performace is a very critical part in this. Wanted to get some feed back upon which is the best framework for batch applications.
    This application would not have too many inserts/updates. It will have selects mainly.
    Can somebody suggest which framework is good Hibernate/Ibatis/JPA ?
    Thanks in advance
    Gautam

    Uppalapati wrote:
    duffymo wrote:
    "batch" usually means "transactional" to me. Why would a batch be mainly SELECTs? Makes no sense.
    Most people wouldn't use Java/JDBC for batch. Better to use the tools that are optimized for your relational database in most cases.
    sorry by stating that a little unclear. It is basically a stand-alone application. It reads messages as they comeby and process the messages. The processing of the messages require a lot of validations to be done (which are dependent upon a lot of parameters in the database and these would require selects). and finally based upon a few criteria's we write the data to the database. Are the validations static, read-only reference data? If so, you can read it once and cache it. Unless the SELECTs are truly dynamic and need to be made every time, perhaps you can save yourself some network traffic that way.
    Caching with Hibernate might make a difference, depending on how dynamic the validations are.
    and my reason for stating that it would have lots of selects is for the validation purpose and some inserts for updating the status.
    duffymo wrote:
    JPA and Hibernate will both require that you have an object model to map to your schema. Do you have that? If not, don't use either of those.
    I have an object model to map with and which is the reason why we are considering Hibernate/Jpa.OK, that's better.
    Either one will do, then. The advantage of JPA is that you don't have to commit to Hibernate, since TopLink and JDO will do as well. You can also use Glassfish or any other Java EE app server that supports EJB3 as well.
    How well do you know Hibernate and/or JPA? The other consideration is your level of skill. Choose the one you know best. Assess the risk if you're just learning and this is a critical project.
    Do you know that JDBC itself can't do the job?
    What other reasons do you have for going this way?
    %

  • Error in JPA Toplink

    Hi,
    I'm using JPA (toplink implementation). When I'm running following named query
    *@NamedQuery(name = "Class.search",*
    query =  "select c "
    + "from Clazz c, Subject sub, School sch "
    + "where sub = c.subject"
    + " and lower(c.name) like :name"
    + " and lower(sub.name) like :subject"
    + " and lower(sch.name) like :school"
    + " and sch = c.school "
    + "order by c.name"
    inside the 11g container, an sqlexception happens. In the exception I can see that the query is translated into following
    SELECT CLASS.ID, CLASS.NAME, CLASS.VERSION_NO, CLASS.CURRICULUM, CLASS.MODIFIED_BY, CLASS.CREATED_BY, CLASS.CREATED_DATE, CLASS.ACTIVE, CLASS.MODIFIED_DATE, CLASS.TEACHING_MATERIAL, CLASS.START_DATE, CLASS.END_DATE, CLASS.SUBJECT_ID, CLASS.SCHOOL_ID FROM CLASS t0, SCHOOL t2, SUBJECT t1 WHERE (((((t1.ID = t0.SUBJECT_ID) AND (LOWER(t0.NAME) LIKE ?)) AND (LOWER(t1.NAME_FO) LIKE ?)) AND (LOWER(t2.NAME) LIKE ?)) AND (t2.ID = t0.SCHOOL_ID)) ORDER BY t0.NAME ASC
         bind => [%, %, %]
    As you can see, the prefix on the class table is class in the select part while it is t0 in the rest of the sql.
    If I run this query in my test outside the container (j2se), then it works fine. I'm using preview 4.
    What is the problem.
    BR
    Jakup

    Hi,
    Here is the exception (I have to cut the last part because it is exceding the maximum length):
    2008-10-06 11:28:48 com.evermind.server.ejb.logging.EJBMessages logException
    SEVERE: [TeachingService:public java.util.List fo.samteld.vitanet.services.TeachingServiceBean.searchClasses(java.lang.String,java.lang.String,java.lang.String)] exception occurred during method invocation: javax.ejb.EJBException: Exception [TOPLINK-4002] (Oracle TopLink - 11g Technology Preview 4 (11.1.1.0.0) (Build 080422)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00904: "CLASS"."SCHOOL_ID": ugyldig identifikator
    Error Code: 904
    Call: SELECT CLASS.ID, CLASS.NAME, CLASS.VERSION_NO, CLASS.CURRICULUM, CLASS.MODIFIED_BY, CLASS.CREATED_BY, CLASS.CREATED_DATE, CLASS.ACTIVE, CLASS.MODIFIED_DATE, CLASS.TEACHING_MATERIAL, CLASS.START_DATE, CLASS.END_DATE, CLASS.SUBJECT_ID, CLASS.SCHOOL_ID FROM CLASS t0, SCHOOL t2, SUBJECT t1 WHERE (((((t1.ID = t0.SUBJECT_ID) AND (LOWER(t0.NAME) LIKE ?)) AND (LOWER(t1.NAME_FO) LIKE ?)) AND (LOWER(t2.NAME) LIKE ?)) AND (t2.ID = t0.SCHOOL_ID)) ORDER BY t0.NAME ASC
         bind => [%, %, %]
    Query: ReadAllQuery(fo.samteld.vitanet.domain.teaching.Clazz); nested exception is: Exception [TOPLINK-4002] (Oracle TopLink - 11g Technology Preview 4 (11.1.1.0.0) (Build 080422)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00904: "CLASS"."SCHOOL_ID": ugyldig identifikator
    Error Code: 904
    Call: SELECT CLASS.ID, CLASS.NAME, CLASS.VERSION_NO, CLASS.CURRICULUM, CLASS.MODIFIED_BY, CLASS.CREATED_BY, CLASS.CREATED_DATE, CLASS.ACTIVE, CLASS.MODIFIED_DATE, CLASS.TEACHING_MATERIAL, CLASS.START_DATE, CLASS.END_DATE, CLASS.SUBJECT_ID, CLASS.SCHOOL_ID FROM CLASS t0, SCHOOL t2, SUBJECT t1 WHERE (((((t1.ID = t0.SUBJECT_ID) AND (LOWER(t0.NAME) LIKE ?)) AND (LOWER(t1.NAME_FO) LIKE ?)) AND (LOWER(t2.NAME) LIKE ?)) AND (t2.ID = t0.SCHOOL_ID)) ORDER BY t0.NAME ASC
         bind => [%, %, %]
    Query: ReadAllQuery(fo.samteld.vitanet.domain.teaching.Clazz)
    javax.ejb.EJBException: Exception [TOPLINK-4002] (Oracle TopLink - 11g Technology Preview 4 (11.1.1.0.0) (Build 080422)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00904: "CLASS"."SCHOOL_ID": ugyldig identifikator
    Error Code: 904
    Call: SELECT CLASS.ID, CLASS.NAME, CLASS.VERSION_NO, CLASS.CURRICULUM, CLASS.MODIFIED_BY, CLASS.CREATED_BY, CLASS.CREATED_DATE, CLASS.ACTIVE, CLASS.MODIFIED_DATE, CLASS.TEACHING_MATERIAL, CLASS.START_DATE, CLASS.END_DATE, CLASS.SUBJECT_ID, CLASS.SCHOOL_ID FROM CLASS t0, SCHOOL t2, SUBJECT t1 WHERE (((((t1.ID = t0.SUBJECT_ID) AND (LOWER(t0.NAME) LIKE ?)) AND (LOWER(t1.NAME_FO) LIKE ?)) AND (LOWER(t2.NAME) LIKE ?)) AND (t2.ID = t0.SCHOOL_ID)) ORDER BY t0.NAME ASC
         bind => [%, %, %]
    Query: ReadAllQuery(fo.samteld.vitanet.domain.teaching.Clazz); nested exception is: Exception [TOPLINK-4002] (Oracle TopLink - 11g Technology Preview 4 (11.1.1.0.0) (Build 080422)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00904: "CLASS"."SCHOOL_ID": ugyldig identifikator
    Error Code: 904
    Call: SELECT CLASS.ID, CLASS.NAME, CLASS.VERSION_NO, CLASS.CURRICULUM, CLASS.MODIFIED_BY, CLASS.CREATED_BY, CLASS.CREATED_DATE, CLASS.ACTIVE, CLASS.MODIFIED_DATE, CLASS.TEACHING_MATERIAL, CLASS.START_DATE, CLASS.END_DATE, CLASS.SUBJECT_ID, CLASS.SCHOOL_ID FROM CLASS t0, SCHOOL t2, SUBJECT t1 WHERE (((((t1.ID = t0.SUBJECT_ID) AND (LOWER(t0.NAME) LIKE ?)) AND (LOWER(t1.NAME_FO) LIKE ?)) AND (LOWER(t2.NAME) LIKE ?)) AND (t2.ID = t0.SCHOOL_ID)) ORDER BY t0.NAME ASC
         bind => [%, %, %]
    Query: ReadAllQuery(fo.samteld.vitanet.domain.teaching.Clazz)
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 11g Technology Preview 4 (11.1.1.0.0) (Build 080422)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00904: "CLASS"."SCHOOL_ID": ugyldig identifikator
    Error Code: 904
    Call: SELECT CLASS.ID, CLASS.NAME, CLASS.VERSION_NO, CLASS.CURRICULUM, CLASS.MODIFIED_BY, CLASS.CREATED_BY, CLASS.CREATED_DATE, CLASS.ACTIVE, CLASS.MODIFIED_DATE, CLASS.TEACHING_MATERIAL, CLASS.START_DATE, CLASS.END_DATE, CLASS.SUBJECT_ID, CLASS.SCHOOL_ID FROM CLASS t0, SCHOOL t2, SUBJECT t1 WHERE (((((t1.ID = t0.SUBJECT_ID) AND (LOWER(t0.NAME) LIKE ?)) AND (LOWER(t1.NAME_FO) LIKE ?)) AND (LOWER(t2.NAME) LIKE ?)) AND (t2.ID = t0.SCHOOL_ID)) ORDER BY t0.NAME ASC
         bind => [%, %, %]
    Query: ReadAllQuery(fo.samteld.vitanet.domain.teaching.Clazz)
         at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:304)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:613)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:467)
         at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:447)
         at oracle.toplink.internal.sessions.IsolatedClientSession.executeCall(IsolatedClientSession.java:117)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:179)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:250)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:583)
         at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2480)
         at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2438)
         at oracle.toplink.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:467)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:874)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:671)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:835)
         at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:445)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:899)
         at oracle.toplink.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2697)
         at oracle.toplink.tools.profiler.DMSPerformanceProfiler.profileExecutionOfQuery(DMSPerformanceProfiler.java:693)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1072)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1058)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1032)
         at oracle.toplink.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:377)
         at oracle.toplink.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:488)
         at fo.samteld.vitanet.services.TeachingServiceBean.searchClasses(TeachingServiceBean.java:112)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:27)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.interceptor.system.SetContextActionInterceptor.invoke(SetContextActionInterceptor.java:44)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:52)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         at oracle.oc4j.security.SecurityServices.doAsPrivileged(SecurityServices.java:182)
         at oracle.oc4j.security.SecurityServices.doAsPrivileged(SecurityServices.java:511)
         at oracle.oc4j.security.JaasModeImpl$DoAsPrivilegedExecutor.execute(JaasModeImpl.java:301)
         at oracle.oc4j.security.JaasModeImpl$BasicExecutor.execute(JaasModeImpl.java:161)
         at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:57)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:58)
         at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:104)
         at TeachingService_LocalProxy_5ndopdi.searchClasses(Unknown Source)
         at fo.samteld.vitanet.ui.backing.teaching.ClassSearchBean$CriteriaPane.search(ClassSearchBean.java:95)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1213)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:62)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:174)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:66)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:62)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:174)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:66)
         at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:153)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl$GrabEvents.broadcastEvents(LifecycleImpl.java:1109)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:283)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:178)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.adfinternal.view.faces.webapp.rich.SharedLibraryFilter.doFilter(SharedLibraryFilter.java:135)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:281)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:69)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:281)
         at oracle.adfinternal.view.faces.activedata.ADSFilter.doFilter(ADSFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:281)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:241)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:198)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:141)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:583)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:334)
         at com.evermind.server.http.HttpRequestHandler.doDispatchRequest(HttpRequestHandler.java:942)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:843)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:658)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:626)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:417)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:189)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:163)
         at oracle.oc4j.network.ServerSocketReadHandler$ClientRunnable.run(ServerSocketReadHandler.java:275)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:237)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:29)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:877)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
         at java.lang.Thread.run(Thread.java:595)
    Caused by: java.sql.SQLException: ORA-00904: "CLASS"."SCHOOL_ID": ugyldig identifikator
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:77)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:111)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:174)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:472)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:422)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1089)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:204)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:861)
         at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:945)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1303)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3556)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3608)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1341)
         at oracle_jdbc_driver_OraclePreparedStatementWrapper_Proxy.executeQuery(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:813)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:539)
         ... 99 more
    javax.ejb.EJBException: Exception [TOPLINK-4002] (Oracle TopLink - 11g Technology Preview 4 (11.1.1.0.0) (Build 080422)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00904: "CLASS"."SCHOOL_ID": ugyldig identifikator
    Error Code: 904
    Call: SELECT CLASS.ID, CLASS.NAME, CLASS.VERSION_NO, CLASS.CURRICULUM, CLASS.MODIFIED_BY, CLASS.CREATED_BY, CLASS.CREATED_DATE, CLASS.ACTIVE, CLASS.MODIFIED_DATE, CLASS.TEACHING_MATERIAL, CLASS.START_DATE, CLASS.END_DATE, CLASS.SUBJECT_ID, CLASS.SCHOOL_ID FROM CLASS t0, SCHOOL t2, SUBJECT t1 WHERE (((((t1.ID = t0.SUBJECT_ID) AND (LOWER(t0.NAME) LIKE ?)) AND (LOWER(t1.NAME_FO) LIKE ?)) AND (LOWER(t2.NAME) LIKE ?)) AND (t2.ID = t0.SCHOOL_ID)) ORDER BY t0.NAME ASC
         bind => [%, %, %]
    Query: ReadAllQuery(fo.samteld.vitanet.domain.teaching.Clazz); nested exception is: Exception [TOPLINK-4002] (Oracle TopLink - 11g Technology Preview 4 (11.1.1.0.0) (Build 080422)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00904: "CLASS"."SCHOOL_ID": ugyldig identifikator
    Error Code: 904
    Call: SELECT CLASS.ID, CLASS.NAME, CLASS.VERSION_NO, CLASS.CURRICULUM, CLASS.MODIFIED_BY, CLASS.CREATED_BY, CLASS.CREATED_DATE, CLASS.ACTIVE, CLASS.MODIFIED_DATE, CLASS.TEACHING_MATERIAL, CLASS.START_DATE, CLASS.END_DATE, CLASS.SUBJECT_ID, CLASS.SCHOOL_ID FROM CLASS t0, SCHOOL t2, SUBJECT t1 WHERE (((((t1.ID = t0.SUBJECT_ID) AND (LOWER(t0.NAME) LIKE ?)) AND (LOWER(t1.NAME_FO) LIKE ?)) AND (LOWER(t2.NAME) LIKE ?)) AND (t2.ID = t0.SCHOOL_ID)) ORDER BY t0.NAME ASC
         bind => [%, %, %]
    Query: ReadAllQuery(fo.samteld.vitanet.domain.teaching.Clazz)
         at com.evermind.server.ejb.EJBUtils.getLocalUserException(EJBUtils.java:96)
         at com.evermind.server.ejb.interceptor.system.AbstractTxInterceptor.convertAndHandleMethodException(AbstractTxInterceptor.java:93)
         at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:52)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         at oracle.oc4j.security.SecurityServices.doAsPrivileged(SecurityServices.java:182)
         at oracle.oc4j.security.SecurityServices.doAsPrivileged(SecurityServices.java:511)
         at oracle.oc4j.security.JaasModeImpl$DoAsPrivilegedExecutor.execute(JaasModeImpl.java:301)
         at oracle.oc4j.security.JaasModeImpl$BasicExecutor.execute(JaasModeImpl.java:161)
         at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:57)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:58)
         at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:104)
         at TeachingService_LocalProxy_5ndopdi.searchClasses(Unknown Source)
         at fo.samteld.vitanet.ui.backing.teaching.ClassSearchBean$CriteriaPane.search(ClassSearchBean.java:95)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1213)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:62)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:174)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:66)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:62)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:174)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:66)
         at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:153)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl$GrabEvents.broadcastEvents(LifecycleImpl.java:1109)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:283)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:178)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.adfinternal.view.faces.webapp.rich.SharedLibraryFilter.doFilter(SharedLibraryFilter.java:135)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:281)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:69)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:281)
         at oracle.adfinternal.view.faces.activedata.ADSFilter.doFilter(ADSFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:281)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:241)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:198)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:141)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:583)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:334)
         at com.evermind.server.http.HttpRequestHandler.doDispatchRequest(HttpRequestHandler.java:942)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:843)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:658)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:626)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:417)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:189)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:163)
         at oracle.oc4j.network.ServerSocketReadHandler$ClientRunnable.run(ServerSocketReadHandler.java:275)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:237)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:29)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:877)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
         at java.lang.Thread.run(Thread.java:595)
    Caused by: Exception [TOPLINK-4002] (Oracle TopLink - 11g Technology Preview 4 (11.1.1.0.0) (Build 080422)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00904: "CLASS"."SCHOOL_ID": ugyldig identifikator
    Error Code: 904
    Call: SELECT CLASS.ID, CLASS.NAME, CLASS.VERSION_NO, CLASS.CURRICULUM, CLASS.MODIFIED_BY, CLASS.CREATED_BY, CLASS.CREATED_DATE, CLASS.ACTIVE, CLASS.MODIFIED_DATE, CLASS.TEACHING_MATERIAL, CLASS.START_DATE, CLASS.END_DATE, CLASS.SUBJECT_ID, CLASS.SCHOOL_ID FROM CLASS t0, SCHOOL t2, SUBJECT t1 WHERE (((((t1.ID = t0.SUBJECT_ID) AND (LOWER(t0.NAME) LIKE ?)) AND (LOWER(t1.NAME_FO) LIKE ?)) AND (LOWER(t2.NAME) LIKE ?)) AND (t2.ID = t0.SCHOOL_ID)) ORDER BY t0.NAME ASC
         bind => [%, %, %]
    Query: ReadAllQuery(fo.samteld.vitanet.domain.teaching.Clazz)
         at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:304)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:613)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:467)
         at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:447)
         at oracle.toplink.internal.sessions.IsolatedClientSession.executeCall(IsolatedClientSession.java:117)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:179)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:250)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:583)
         at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2480)
         at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2438)
         at oracle.toplink.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:467)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:874)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:671)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:835)
         at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:445)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:899)
         at oracle.toplink.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2697)
         at oracle.toplink.tools.profiler.DMSPerformanceProfiler.profileExecutionOfQuery(DMSPerformanceProfiler.java:693)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1072)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1058)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1032)
         at oracle.toplink.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:377)
         at oracle.toplink.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:488)
         at fo.samteld.vitanet.services.TeachingServiceBean.searchClasses(TeachingServiceBean.java:112)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:27)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.interceptor.system.SetContextActionInterceptor.invoke(SetContextActionInterceptor.java:44)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
         at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50)
         ... 65 more
    Caused by: java.sql.SQLException: ORA-00904: "CLASS"."SCHOOL_ID": ugyldig identifikator
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:77)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:111)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:174)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:472)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:422)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1089)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:204)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:861)
         at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:945)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1303)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3556)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3608)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1341)
         at oracle_jdbc_driver_OraclePreparedStatementWrapper_Proxy.executeQuery(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:813)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:539)
         ... 99 more
    BR
    Jakup

  • How to handle journal table using JPA+TopLink

    Hi,
    I am using JDev10.1.3.3 with Swing and EJB + JPA + TopLink using Oracle database. Every business table has a journal table. Does TopLink have any journal features or do I have to write my own code to insert data into the journal table.
    Thanks,
    Jim

    Depends what's in your journal table? TopLink does have support for historization (see HistoryPolicy or docs).
    Otherwise you could use TopLink events to insert into the table, or use database triggers.
    -- James : http://www.eclipselink.org

  • JPA Toplink OneToMany - ManyToOne Relation will not stored in DB

    Hi
    I am getting the error while inserting the data into Two tables by using the ManyToOne realation.
    i am using 2 tables. In parent table i am giving
    @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER,mappedBy="meterInfo")
    @JoinColumn(name="METERID")
    private List<MeterSub> meterSubs=null;
    subtable i am giving
    @ManyToOne(optional=false,targetEntity=com.nexant.mdm.dto.MeterInfoDTO.class)
    @JoinColumn(name="METERID",nullable=false, insertable=false, updatable=false)
    private MeterInfoDTO meterInfo;
    i am inserting the data by using the test class like this:
    MeterInfoDTO mi = new MeterInfoDTO();
    mi.setMeterID(4);
    MeterSub ms = new MeterSub();
    ms.setMeterInfo(mi);
    ms.setMeterData("meterData12");
    ms.setMeterSubPk("103");
    //ms.setMeterID(2);
    List<MeterSub> set = new ArrayList<MeterSub>();
    set.add(ms);
    mi.setMeterSubs(set);
    mi.setMeterName("Sample Meter NAme");
    mi.setMeterTimeZone("TZ");
    Last i am saving the data.
    while inserting the data its giving the following error:
    ORA-02291: integrity constraint (SYSTEM.SYS_C0010451) violated - parent key not found
    Error Code: 2291
    Call: INSERT INTO METERSUB (METERSUBPK, METERDATA, METERID) VALUES (?, ?, ?)
    means its not taking METERID from parent and its giving 0. thats why the error coming like this.
    Can any please help me to resolve this
    Thanks
    Shannu

    Hi Tolls,
    i have one doubt while using the JPA Toplink.
    In my table it have primary key with 2 columns menas composite key acting as a primary key.
    So how i have to declare these fields in POJO class
    and also how to represent these Class and primary key in ONe to One realtion or Many to one relation.
    @ManyToOne(optional=true,targetEntity=com.nexant.mdm.dal.eo.Capability.class)
    @JoinColumn(name="CapabilityID",nullable=false, insertable=true, updatable=false)
    private Capability capability;
    here Capabity is the POjo calss and CapabilityID is the primary key , if in place of CapabilityID i have 2 keys acting as a primary key.
    So how can i represent this?
    waiting for ur valuble response :)

  • JPA/Toplink Tutorials

    Hi ,
    iam looking for advanced JPA/Toplink Documentation (Books) , can any one help me on that ,
    Thanks
    Best Regards,

    TopLink documentation is here: http://www.oracle.com/technology/products/ias/toplink/doc/index.html, including the Developer's Guide.
    JPA resources are listed here: http://www.oracle.com/technology/products/ias/toplink/jpa/resources-index.html

  • How to write query for this in TopLink ?

    I am doing a simple search in jsp where the search will the based on the choices chosen by user.
    I had given 3 check boxes for those choices.
    The problem is, query will be based on the choice or choices chosed by the user.
    How to write query for this in TopLink ?
    Thanks in Advance..
    Jayaganesh

    Try below solution, it is NOT best solution but might work:
    Declare @Questions TABLE (QuestionID INT, QuestionText Varchar(100))
    INSERT INTO @Questions
    VALUES (1, 'Comment'), (2, 'Score')
    DECLARE @Answers TABLE (authkey INT, QuestionID INT, questiontext VARCHAR(100), answertext VARCHAR(100))
    INSERT INTO @Answers
    VALUES (101, 1, 'comment', 'hi!!'), (101, 2, 'score', '4'), (102, 1, 'comment', 'excellent'), (102, 2, 'score', '5'), (103, 2, 'score', '6'), (104, 2, 'score', '8')
    SELECT
    A.AuthKey
    ,Q.QuestionID
    ,Q.QuestionText
    ,A.AnswerText
    FROM
    @Questions Q
    INNER JOIN @Answers A ON Q.QuestionID = A.QuestionID
    UNION
    SELECT
    A.AuthKey
    ,Q.QuestionID
    ,Q.QuestionText
    ,Null
    FROM
    @Questions Q
    CROSS JOIN @Answers A
    WHERE
    NOT EXISTS (SELECT 1 FROM @Answers SubQry WHERE SubQry.AuthKey = A.AuthKey AND SubQry.QuestionID = Q.QuestionID)
    Output
    AuthKey | QuestionID
    | QuestionText
    | AnswerText
    101 | 1 | Comment | hi!!
    101 | 2 | Score | 4
    102 | 1 | Comment | excellent
    102 | 2 | Score | 5
    103 | 1 | Comment | NULL
    103 | 2 | Score | 6
    104 | 1 | Comment | NULL
    104 | 2 | Score | 8
    Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.

  • JPA: Toplink vs Hibernate

    I am using netbeans 5.5 and I want to use JPA. I am in favor of hibernate, but why does the netbeans has toplink being the default persistence library of JPA? What are the difference between toplink and hibernate if I'll be using JPA?
    By the way, I've seen an article "Using JPA in tomcat" and I would really like to use JPA in tomcat as I think it is much faster and lighter than Glassfish. But the article also uses toplink as the persistence library? Could someone guide me in using hibernate?

    This is an video from NetBeans site. Take a look.
    It will open your eyes about Hibernate and TopLink and JPA after you checking the codes that will be generated on your own system application.
    http://www.netbeans.org/download/flash/netbeans_6_gui_builder/netbeans_6_gui_builder.html

  • JPA toplink Query cache

    Any idea when performing Query's with Hint but no L2 cache enabled ? Will that object cached / lazyloaded /enriched on access ?
    By the way, whats the default L2 cache setting, is it enable or disabled ? If enable where does it stores, in memory ?
    Thanks
    Newbie

    A shared (L2) cache is enabled by default in TopLink/EclipseLink.
    The cache is in memory.
    Using a query cache, without the shared cache makes little sense, you should use both, or none.
    What will happen if you do is the query cache will be isolated to the session the same as the object cache, so you will get query cache hits for the duration of the persistence context/transaction. i.e. it will be an L1 query cache.
    To configure the cache see,
    http://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching

  • JPA, Toplink, Query with getSingleResult returns Vector, should it?

    I don't understand why when I do a simple query "Select count(*) From ...." and get use the EntityManager my code is something like this:
    getEntityManager().createNativeQuery(sql).getSingleResult()
    and what I get is a Vector object that has inside a BigDecimal object. I wonder how portable this is if I use hibernate. I bought a book that was written by a couple of guys from Oracle and their example returns a Object array instead of a Vector even when getResultList() function is called.
    I can't find any documentation where it indicates what is returned from getSingleResult() and getResultList().
    Any help from any gurus are most welcomed....

    Bug 2219 (https://glassfish.dev.java.net/issues/show_bug.cgi?id=2219 ) deals with native queries not returning the correct types unless it is to return an entity or results specified using a ResultRetMapping.
    Michael's blog examples are all using JPQL which do not have this problem, so you could switch to using JPQL to get the proper results as well.
    Best Regards,
    Chris

  • JPA/TopLink

    Hi Everyone,
    I am using JPA with vendor implementation toplink.
    For some complex queries like
    START WITH EMPLOYEE_ID = 100 CONNECT BY PRIOR EMPLOYEE_ID = MANAGER_ID ORDER SIBLINGS BY LAST_NAME, I am plannign to use TOplink api like ReadAllQuery and ExpressionBuilder.
    As per my understanding, We are using JPA to have Vendor independent api and implementaion will be provided in persistence.xml.
    If i use some toplink api's ,Tomorrow If i want to change the vendor from Toplink to hibernate. I need to change Toplink code to hibernate in my services.
    Is there anyway i can use JPA alone to get all the work done... Thanks in advance for all your suggestions.

    JPQL does not support connect by. If you need to use connect by, you must either use vendor specific functionality, or a native SQL query.
    James : http://www.eclipse.org/eclipselink/

  • Using an Oracle SQL Function from JPA/TopLink

    How do I get the return value from a simple (one string input parameter, returns a string) Oracle SQL Function?
    Thanks!

    If you mean calling a stored function in Oracle, you might try something like:
        ValueReadQuery vrq = new ValueReadQuery();
        SQLCall call = new SQLCall("begin ###res := pkg.funcInp(#inp); end;");
        vrq.setCall(call);
        Query q = em.createNativeQuery("");   // we need a Query; any query would do; we replace its contents below
        ((EJBQuery)q).setDatabaseQuery(vrq);
        q.setParameter("inp", "paramValue");
        String result = (String)q.getSingleResult();
        // #=input; ###=output; ####=input/output;
        // if you want to explicitly specify the type of an output parameter, use #### instead of ###,
        // because pure "output" parameters are always treated as java.lang.StringThis will only work in TopLink Essentials, though. I don't know how to do it in Hibernate. I have dealt mainly with TopLink, and just a little with Hibernate.
    In my opinion, it's a HUGE omission not to have support for stored procedures in JPA. Virtually every project I have worked on (in two large companies) has consisted of a large portion of code in stored procedures (sometimes as much as 50% of the overall code). It's a pain to have to go through all that trouble to call the stored procedures.
    Also, pay special attention to TopLink's shared L2 cache. If a stored procedure changes something in the database, TopLink won't know about it and chances are that you will end up with stale objects in the cache which you will either have to refresh, or you'd have to invalidate TopLink's cache for these objects.
    Best regards,
    Bisser

  • JPA Toplink, class cast exception when casting class A to class A

    I get a really strange exception from Toplink JPA. I used netbeans to create a persistence.xml and I generated a class (entity) from the table in a DB. Everything works fine, when I create a select query, I get the list of objects and the list is correctly typed. I can the objects in the list in debug mode with every field correctly set. But then I need to start working with the list, so I iterate through the list. And then I get ClassCastException from class A to class A (when A is the canonical name of the entity class).
    I was working with JPA for some time but never seen that. I am using glassfish v2, mysql, netbeans 6.1. I could post the classes and persistence xml, but persistence.xml is really simple (no class definitions) and the class is annotated by netbeans. Every field is annotated like this:
    @Column(name = "name", nullable = false)
    And Date columns have
    @Temporal(TemporalType.TIMESTAMP)
    The whole class is annotated with @Table.
    Does anyone has any idea, what can be wrong?

    DrClap wrote:
    Make sure your URLClassLoader cannot load the IAdapter class.
    That is not exactly correct. He needs to make sure his URLClassloader has access to the IAdapter class. Sure, it should not load it on its own, but if requested the URLClassloader should be able to ask a parent to load IAdapter. Which in the end looks the same. But is not the same.
    So set the parent classloader of your URLClassloader to a classloader capable of loading IAdapter.

  • EJBQL query problem in JPA

    I am developing an Enterprise application that uses JPA and toplink as the persistence provider. It uses MYSQL 5.1.
    The query used in the Entity class is :
    @NamedQueries({@NamedQuery(name = "AirtravelsDynamic.findAllEconomyFlights", query = "select NEW com.inter.transfer.Response(rf.flightno,d.economyseats,rf.ecofare,rf.arrtime,rf.depttime) from AirtravelsDynamic d LEFT JOIN d.refId rf where rf.source=?1 and rf.destination=?2 and d.availdate between ?3 and ?4") })
    This application is giving the following exception:
    Exception Description: Error compiling the query [AirtravelsDynamic.findAllEconomyFlights: select NEW com.inter.transfer.Response(rf.flightno,d.economyseats,rf.ecofare,rf.arrtime,rf.depttime) from AirtravelsDynamic d LEFT JOIN d.refId rf where rf.source=?1 and rf.destination=?2 and d.availdate between ?3 and ?4], line 1, column 40: invalid navigation expression [rf.flightno], cannot navigate expression [rf] of type [int] inside a query.
    Local Exception Stack:
    Exception [TOPLINK-8029] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EJBQLException
    Exception Description: Error compiling the query [AirtravelsDynamic.findAllEconomyFlights: select NEW com.inter.transfer.Response(rf.flightno,d.economyseats,rf.ecofare,rf.arrtime,rf.depttime) from AirtravelsDynamic d LEFT JOIN d.refId rf where rf.source=?1 and rf.destination=?2 and d.availdate between ?3 and ?4], line 1, column 40: invalid navigation expression [rf.flightno], cannot navigate expression [rf] of type [int] inside a query.
    at oracle.toplink.essentials.exceptions.EJBQLException.invalidNavigation(EJBQLException.java:430)
    at oracle.toplink.essentials.internal.parsing.DotNode.checkNavigation(DotNode.java:141)
    at oracle.toplink.essentials.internal.parsing.DotNode.validate(DotNode.java:97)
    at oracle.toplink.essentials.internal.parsing.ConstructorNode.validate(ConstructorNode.java:97)
    at oracle.toplink.essentials.internal.parsing.SelectNode.validate(SelectNode.java:329)
    at oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java:229)
    at oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java:211)
    at oracle.toplink.essentials.internal.parsing.ParseTree.validate(ParseTree.java:201)
    at oracle.toplink.essentials.internal.parsing.EJBQLParseTree.populateReadQueryInternal(EJBQLParseTree.java:134)
    at oracle.toplink.essentials.internal.parsing.EJBQLParseTree.populateQuery(EJBQLParseTree.java:108)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:219)
    at oracle.toplink.essentials.queryframework.EJBQLPlaceHolderQuery.processEjbQLQuery(EJBQLPlaceHolderQuery.java:111)
    at oracle.toplink.essentials.internal.sessions.AbstractSession.processEJBQLQueries(AbstractSession.java:2059)
    at oracle.toplink.essentials.internal.sessions.AbstractSession.processEJBQLQueries(AbstractSession.java:2046)
    at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:724)
    at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:604)
    at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:280)
    at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:229)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:93)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:126)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:120)
    at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:91)
    Any help is appreciated.
    Thanks in advance.

    What are you trying to do exactly? The way you've used LEFT JOIN is not correct if d.refId is an integer. LEFT JOIN is used to retrieve a set of entities where that set may not exist. It doesn't look like refId is a set of anything, just an integer.
    It looks like maybe you intended to have a foreign key relationship between AirtravelsDynamic and some other entity. In that case you probably want to model your AirtravelsDynamic entity as having a many-to-one relationship with the entity (let's call it ref.)
    The relationship would look something like:
    @Entity
    public class AirtravelsDynamic
       @ManyToOne
       @JoinColumn(name="refId")
       private Ref ref;
    }Then your query would read:
    SELECT new com.inter.transfer.Response(d.ref.flightno, d.economyseats,
                                           d.ref.ecofare, d.ref.arrtime,
                                           d.ref.depttime)
      FROM AirtravelsDynamic d
    WHERE d.ref.source = :refSource
       AND d.ref.destination = :refDest
       AND d.availDate between :lowDate and :highDateIf I'm misunderstanding your intent, let me know and I'll try to help you resolve the problem.

Maybe you are looking for

  • Goods Receipt Value line item wise

    Hi Experts, My client wants show Goods Receipt Value line item wise at the time of GR entries. He wants show GR Value before saving the GR document. Please advise me how it is possible. Thanks in advance, Chandhu

  • Having Problem in access to Source Code Control System (URGENT help needed)

    I am using JDeveloper 9i first time. The repository is in Oracle 8i. I have established a connection from JDeveloper 9i to Oracle 8i repository running on Sun Solaris. We have created a shared area and my colleague have checked-in some files. I have

  • Power Supply LCD TV

    Two symptoms of a possible power problem with my  Insignia 32" (NS-LBD32X=10A) are an occasional burst of static in any mode and in DVD mode an occasional screen freeze. I'm not sure if the two problems are related but wondering if a surge protector

  • Have recently upgraded to Mavericks.  Since then, I have been unable to upload images to a photo lab in Melbourne - what is wrong?

    I work as the photographer in a small Photography studio and we use a Lab in Melbourne to retouch and print our photographs for our clients.  This Lab (Nulab) has software downloaded to my Mac from their website which I use to upload the images, requ

  • Designer vs AcroForms

    Is it possible for JavaScripts that work in Acrobat forms to work in Designer forms as well? I like the popup calendar available in Designer, and the drag-and-drop form fields, but I have lots of useful JavaScripts that work in Acrobat forms that I w