Toplink Essentials in Jdeveloper 10.1.3.1: production or experientment?

Dear All,
i have a question about the toplink essentials bundled with the jdeveloper 10.1.3.1 production release.
Is this version of production quality or just for experientment?
is it stable enough to developer application on top of it ??
thanks.

Dear Shay,
Thank you.
Then i can persuade my colleague to use it to develop our small, new application.
BTW, will oracle provide official support if there is any problem related to toplink essentials
in 10.1.3.1? my company sign contract and pay for technical support.(through metalink)
thank you.

Similar Messages

  • Strange classloader experience with toplink-essentials on Oc4j-10.1.3.3.0

    Hi,
    I am teaching classes at the Eotvos University/Budapest on a topic where OC4J has been used for 2 years. Students use jdeveloper (regularly updated) to create webapps with EJB3.0+toplink backends. They test their projects first with the JDeveloper embedded OC4J, but after that they deploy it on a central server running standalone OC4J.
    Students make quite an intensive and versatile use of the OC4J server, a noteworthy stress-test you may find interesting! The server is a Ubuntu Linux with JDK_1.5.0_14.
    1. The first known issue is that after about 10 projects are deployed (small class projects 3-4 EJBs, 3-4 JSP-s each), oc4j regularl goes into a "runaway" mode, i.e. the CPU utilization of the JVM process goes up to 99-100%. Static web content is still available, but all applications stop responding. I can state pretty safely that the applications deployed are fairly harmless and it is not even necessary to run them to make this happen. I.e. after 10-15 apps are depoyed it is enough to start the admin-client.jar or the admin console to experience this problem. (The applications have no problem individually: last year after these issues occurred, we installed them individually for grading and nothing like this happened).
    Let me point out that SO FAR this happened with Oc4j-10.1.3.1 and Oc4j-10.1.3.2 only, and this was the main reason we swithed to Oc4j-10.1.3.3.0
    2. Another issue that exists both with the earlier versions and 10.1.3.3.0 is that applications need to include the toplink-essentials.jar explicitely if they use EJB3.0 entities. It appears to me that this should not be neessary as there are default definitions for that in config/server.xml (a shared-library definition for toplink-essentials), and in config/system-application.xml (a corresponding import-shared-library tag), but still their applications cannot be deployed because of the follwing error:
    Deploy error: Deploy error: Operation failed with error:
    Hiányzó osztály: oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
    FĂĽggĹ' osztály: com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl
    BetöltĹ': oc4j:10.1.3
    Kódforrás: /opt/oc4j_101330/j2ee/home/lib/oc4j-internal.jar
    (On our machines, JDK displays some errors in Hungarian: HiányzĂł osztály=Missing class; FĂĽggĹ' osztály=Dependent class; BetöltĹ'=Loader; KĂłdforrás=Code source.)
    To fix this issue, we used a workaround, i.e. their orion-application.xml is regularly extended with something like:
    <library path="/opt/oc4j/toplink/jlib/toplink-essentials.jar"/>
    And this solved the problem. Can you explain this?
    3. Now, with 10.1.3.3.0 this did not help much either. Although the toplink-essentials.jar was found, another nasty exception happened in the server still during deployment:
    Caused by: java.lang.NoSuchMethodException: oracle.toplink.essentials.platform.server.oc4j.Oc4jPlatform.<init>(oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl)
    at java.lang.Class.getConstructor0(Class.java:2678)
    at java.lang.Class.getConstructor(Class.java:1629)
    at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.updateServerPlatform(EntityManagerSetupImpl.java:309)
    Apparently a class in toplink-essentials.jar (version 2, build 41, i.e. the one that comes with oc4j) cannot properly invoke a the constructor of another class IN THE SAME JAR.
    I checked everything, even unzipped and checked the class signatures, and also made sure that there is no other toplink-essentials.jar in the classpath. Still the error remained.
    FInally, I tried to add the above libary tag to $OC4J_HOME/config/apllication.xml instead of the applications local orion-application.xml, and - voila!!! - it WORKS now!
    Can you explain all this to me? From the documentation the location of the <library> tag in the descriptor files should not amke any difference, but still it seems to do.
    Regards: Arpad Bakay

    Seems to be a bug. That was the response from Oracle support (Metalink)
    Response:
    Your issue seems to be related to bug 5594702 - Abstract: EJB30 ENTITY BEAN WITH @ID AND @COLUMN ANNOTATION FAILS TO DEPLOY ON AIX.
    There is an issue with the IBM JDK/JRE 1.5's processing of annotations.
    Links:
    http://www.theserverside.com/discussions/thread.tss?thread_id=37764
    http://www-128.ibm.com/developerworks/forums/dw_thread.jsp?forum=367&thread=112543&cat=10
    When processing annotations it returns boolean values as false.
    Work-around:
    Fully specify the @Column annotation's boolean values. If insertable and updatable are set to false (which will happen due to this bug) then TopLink sets the PK
    mapping to read-only and the exception seen is expected.
    Note: nullable attribute of the @Colmun is not used in the EJB3/JPA preview of 10.1.3.0 If the customer MUST override the default column name then they should use:
    @Column(name="column-name", insertable=true, updatable=true)
    If they do not wish to override the default column name then simply do not use an @Column annotation.
    It can be deleted or commented out in the JDev generated code.
    There are two reported annotation processing issues with the AIX JVM. One was fixed in SR1 and the other is fixed
    in SR3 (due out Oc 11 - today). Upgrading to these more recent JVM releases may also address this issue.
    RECOMMENDED SOLUTIONS:
    1. Upgrade the IBM AIX JVM to SR3.
    OR
    2. Fix all generated @Column annotations as described above

  • Replacing Oracle Toplink with TopLink Essentials

    Is it possible to force OC4J to use TopLink Essentials by default
    instead of Oracle TopLink?

    Hi
    Replace your toplink jars in your server with the new
    jars. it should pick up automatically
    Regards,
    RaghavendraHi,
    I am trying to use the latest version of Toplink Essentials with the embedded OC4J in JDeveloper 10.1.3.
    Can you please be more specific?
    Which JAR files must be replaced?
    Thanks in advance,
    George

  • Toplink support for JPA vs. Toplink Essentials

    I think I read that Toplink has some support for EJB3/JPA as does Toplink Essentials.
    What is the difference in features?
    If one has a 10.1.3 app server license, should Toplink be used instead of Toplink Essentials for EJB3/JPA applications?
    Does the Mapping Workbench produce JPA object-relational mapping annotations or XML?
    Thank you.
    Richard Catlin

    Hi Robert,
    I'm not sure which comments you were directing specifically to Dali vs. JDeveloper but I'll try and address them from a Dali perspective. I do want to point out that Dali is at 0.5 and so it is still under development.
    yes you get a basic 1:1 entity from your databasetables...When generating Entities from tables, Dali will generate 1:1 and 1:many relationships based on database FK constraints.
    @temporary annotations are not inserted if you have a Date oder Calendar type.Also when generating Entities from tables Dali will generate an instance variable of java.sql.Date for a database date column. java.sql.Date does not require an @Temporal annotation.
    What's missing right now is a problem marker for missing @Temporal on java.util.Date and java.util.Calendar.
    If you want to rename attributes or methods it's a lot of manual work to do... because >@Column annoations are not inserted, if they do not exist because of >dbname=attributenameThere is a bugzilla bug opened for this refactoring support. https://bugs.eclipse.org/bugs/show_bug.cgi?id=136333 Fortunately in Dali if you rename a class or attribute (field/getter) and your explicit or default mappings are broken you will get a problem marking on the attribute and in the Problems view so you can fix it rather than finding out at runtime.
    generics are not inserted in the returnvalues of the methods...Generated Entities do use generics correctly e.g.:
    public class Publisher implements Serializable {
         @OneToMany(mappedBy="publisher")
         private Set<Title> titles;
         public Set<Title> getTitles() {
              return this.titles;
         public void setTitles(Set<Title> titles) {
              this.titles = titles;
    ...--Shaun                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Toplink Essentials final in Embedded OC4J - When?

    Hi,
    As far as i know (please correct me if I am wrong), the current release of JDeveloper (10.1.3.x) works with old Toplink Essentials version that covers an early draft of the JPA specs.
    My question is: when will the final version of Toplink Essentials be available in the Embedded version of the OC4J server? What about the standalone OC4J version and the complete Oracle Application server itself?
    Thanks in advance,
    George

    Complete EJB 3.0 implementation is planned for version 10.1.3.1
    We are hoping to get a developer preview out on OTN of 10.1.3.1 soon.

  • Unable to deploy Web App using JPA TopLink Essentials in Tomcat5.5.17

    Hi All,
    I am trying to deploy a Web App ( used Top Link Essentials ) to Tomcat and i am getting the following Error..
    I am strating tomcat using -javaagent:/Path/To/spring-agaent.jar
    Dec 14, 2006 9:52:46 AM org.apache.catalina.loader.WebappClassLoader loadClass
    INFO: Illegal access: this web application instance has been stopped already.  Could not load oracle.toplink.essentials.internal.weaving.ClassDetails.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
    java.lang.IllegalStateException
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1238)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at oracle.toplink.essentials.internal.weaving.TopLinkWeaver.transform(TopLinkWeaver.java:84)
            at org.springframework.orm.jpa.persistenceunit.ClassFileTransformerAdapter.transform(ClassFileTransformerAdapter.java:56)
            at sun.instrument.TransformerManager.transform(TransformerManager.java:122)
            at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:155)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1812)
            at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:866)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1319)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at java.lang.Class.getDeclaredConstructors0(Native Method)
            at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
            at java.lang.Class.getConstructor0(Class.java:2671)
            at java.lang.Class.newInstance0(Class.java:321)
            at java.lang.Class.newInstance(Class.java:303)
            at org.apache.myfaces.application.ApplicationImpl.createComponent(ApplicationImpl.java:396)
            at com.sun.faces.config.ConfigureListener.verifyObjects(ConfigureListener.java:1438)
            at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:509)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
            at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608)
            at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535)
            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
            at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
            at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
            at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
            at org.apache.catalina.core.StandardService.start(StandardService.java:450)
            at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
            at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
            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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) Thanks
    Sateesh

    Spring 2.0 provides custom support for TopLink Essentials in Tomcat out-of-the-box. You should follow the instructions here: http://static.springframework.org/spring/docs/2.0.x/reference/orm.html#orm-jpa-setup-lcemfb-tomcat
    Essentially, Spring provides a custom class loader for Tomcat and doesn't use an agent.
    --Shaun                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to use (toplink essentials)JPA with EJB 2.1 spec in oc4j 10.1.3.2

    I have an application that uses EJB 2.1 spec with SLSB (no entity beans) and uses DAO pattern with hibernate2 for persistence. I want to replace hibernate with toplink-essentials (JPA). I cannot upgrade the EJB spec version as we use some thirdparty beans. The application uses DAO pattern so I should be able to hook in a new toplink DAO impl. What I am struggling with is how do I get hold of the EntityManagerFactory in my EJB 2.1 SLSB. Also I need CMT with XA transactions as our application interacts with jms and database using MDBs and SLSBs.
    Prantor

    You should be able to use Persistence.createEntityManagerFactory(<your-persistence-unit-name>, properties), and create your EntityManager from that.
    To have TopLink integrated with JTA, in your persistence.xml (or properties) you need to use a JTA DataSource, and set the ServerPlatform for your JEE server.

  • Problems with Toplink Essentials on OracleAS 10.1.3.1 / OC4J 10.1.3.2

    Hi, all.
    I successfully installed OracleAS 10.1.3.0 and applied patch 5906151 to update do OAS 10.1.3.1 and OC4J 10.1.3.2, running on both Windows and AIX.
    I deployed a j2ee app (ejb-jar and ear/war separatelly) on both. My application runs very well on Windows platform, but fails on AIX.
    In order to get my app running with EJB 3.0, JPA and Toplink, I had to copy toplink-essentials.jar to $ORACLE_HOME/j2ee/home/applib/ directory.
    On AIX I was getting the following error:
    exception occurred during method invocation: javax.ejb.EJBException:
       java.lang.RuntimeException: javax.ejb.EJBException: oracle.toplink.essentials.exceptions.ValidationException
              Exception Description: Error encountered when building the @NamedQuery [MyClass.findAll]
                 from entity class [class oracle.toplink.essentials.internal.ejb.cmp3.metadata.queries.MetadataNamedQuery].
             Internal Exception: java.lang.IllegalStateException: ClassLoader "myApp.root:0.0.1"
               (from  in /oracle/product/10.1.3.0/j2ee/OC4J_1/applications/myApp/):
      This loader has been closed and should not be in use.;
    But I found a known issue on Metalink [Note:427650.1] (bug 5928776) - https://metalink.oracle.com/metalink/plsql/f?p=130:14:11405609768040641618::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,427650.1,1,1,1,helvetica
    I replaced the toplink-essentials.jar and toplink-essentials-agent.jar as stated on the metalink for the version build 41, and tested. And later for the latest build 58.
    But I am getting another error message:
    Exception [TOPLINK-46] (Oracle TopLink Essentials - 2.0 (Build b58-rc1 (08/05/2007))): oracle.toplink.essentials.exceptions.DescriptorException
    Exception Description: There should be one non-read-only mapping defined for the primary key field [MY_TABLE.MY_FIELD].
    Descriptor: RelationalDescriptor(xyz.MyClass --> [DatabaseTable(MY_TABLE)])
    Runtime Exceptions:
    ; nested exception is: javax.persistence.PersistenceException: Exception [TOPLINK-0] (Oracle TopLink Essentials - 2.0 (Build b58-rc1 (08/05/2007))): oracle.toplink.essentials.exceptions.IntegrityException
    Descriptor Exceptions:
    ---------------------------------------------------------Does anyone have any idea about this issue?

    Seems to be a bug. That was the response from Oracle support (Metalink)
    Response:
    Your issue seems to be related to bug 5594702 - Abstract: EJB30 ENTITY BEAN WITH @ID AND @COLUMN ANNOTATION FAILS TO DEPLOY ON AIX.
    There is an issue with the IBM JDK/JRE 1.5's processing of annotations.
    Links:
    http://www.theserverside.com/discussions/thread.tss?thread_id=37764
    http://www-128.ibm.com/developerworks/forums/dw_thread.jsp?forum=367&thread=112543&cat=10
    When processing annotations it returns boolean values as false.
    Work-around:
    Fully specify the @Column annotation's boolean values. If insertable and updatable are set to false (which will happen due to this bug) then TopLink sets the PK
    mapping to read-only and the exception seen is expected.
    Note: nullable attribute of the @Colmun is not used in the EJB3/JPA preview of 10.1.3.0 If the customer MUST override the default column name then they should use:
    @Column(name="column-name", insertable=true, updatable=true)
    If they do not wish to override the default column name then simply do not use an @Column annotation.
    It can be deleted or commented out in the JDev generated code.
    There are two reported annotation processing issues with the AIX JVM. One was fixed in SR1 and the other is fixed
    in SR3 (due out Oc 11 - today). Upgrading to these more recent JVM releases may also address this issue.
    RECOMMENDED SOLUTIONS:
    1. Upgrade the IBM AIX JVM to SR3.
    OR
    2. Fix all generated @Column annotations as described above

  • Accessing the Session in Toplink Essentials

    I try access session by this way:
    http://ontoplink.blogspot.com/2007/01/accessing-session-in-toplink-essentials.html
    and get exception:
    (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: Could not find the session with the name [my_name] in the session.xml file []
    Is session.xml needed for this ? I hope not, because it requires project.xml and it maybe require some another... All what I need is:
    session.getEventManager().addListener(myEventListener);
    to force toplink switch database schema in listener preLogin method. In Hibernate, it can be done by one line in config file.
    Lumir

    OK, I tried obtain session BEFORE creating EntityManagerFactory and EntityManager.
    Now when obtaining it AFTER creating EMF and EM, it works.
    But this not solve problem with change db schema, because AFTER create EMF and EM, session is logged in and EventListener preLogin isn't called.
    Can anyone point me, how to change db schema ? I know it for connection defined using toplink.jdbc.* properties, but not for JNDI:
    public class ToplinkSessionCustomizer implements SessionCustomizer
    public void customize(Session session) throws Exception
              if(jdbcUrl == null)
                   // JDBC URL is not set, assume JNDI lookup
                   JNDIConnector connector = (JNDIConnector) session.getLogin().getConnector();
                   connector.setLookupType(JNDIConnector.STRING_LOOKUP);
                   // 1. Not works, cause NPE
                   // at oracle.toplink.essentials.descriptors.ClassDescriptor.verifyTableQualifiers(ClassDescriptor.java:3518)
                   session.getDatasourcePlatform().setTableQualifier(schema);
                   SessionEventAdapter preLoginEventListener = new SessionEventAdapter()
                   // Listen for preLogin events
                        public void preLogin(SessionEvent event)
                        event.getSession().getLogin().setTableQualifier("myschema");
                   // 2. Not works, eventManager is null, cause NPE !
                   session.getEventManager().addListener(preLoginEventListener);
              else
    // This works OK
                   DatabaseLogin login = session.getLogin();
                   login.useOracleThinJDBCDriver();
                   login.setDatabaseURL(jdbcUrl);
                   login.setUserName(userName);
                   login.setPassword(password);
                   login.setTableQualifier(schema);
         }

  • Toplink Essentials: how can I not to auto persist computed/virtual column

    Tags: Toplink Essentials, JPA, virtual columns
    Hi All,
    This appears to be a newbie question. But I cannot get it solved.
    First, my system is Eclipse + TOPlink essentials.
    My relational db table has a computed column. It is derived from a column of the same table.
    create table WINE(
    WINE_NAME VARCHAR2(25),
    WINE_STORAGE_DATE DATE,
    VINTAGE AS (EXTRACT(YEAR FROM WINE_STORAGE_DATE))
    In my JAVA entity, I would like to map VINTAGE into a "auto-generated" field. In this way, when I update relational db table, VINTAGE won't be in the JPA generated INSERT statement, but I can query the VINTAGE into my java entity/object.
    I tried the following JPA annotation in my java entity class.
    @Entity
    public class Wine implements Serializable {
    @GeneratedValue private Integer VINTAGE;
    I can query db table -- VINTAGE flows from db table to my java object. But when I update table ( I left VINTAGE un-specified ), I get the following error:
    Internal Exception: java.sql.SQLException: ORA-54013: INSERT operation disallowed on virtual columns
    Error Code: 54013
    Call: INSERT INTO WINE(WINE_NAME, WINE_STORAGE_DATE, VINTAGE) VALUES (?, ?, ?)
         bind => PinotNoir, 2003-01-05 00:00:00.0, null
    Any suggestions on what annotation tage I should use to tell the JPA Provider not to include VINTAGE in the auto-generated INSERT statement?
    Thank you very much.
    Jing
    Edited by: user11935396 on Sep 25, 2009 1:36 PM
    Edited by: user11935396 on Sep 25, 2009 1:37 PM

    I am not sure if your annotation @GeneratedValue is proper. According to javadoc "Provides for the specification of generation strategies for the values of primary keys. The GeneratedValue annotation may be applied to a primary key property or field of an entity or mapped superclass in conjunction with the Id annotation."
    I would rather try to annotate VINTAGE as @Column(insertable=false, updatable=false)

  • TopLink Essentials: Using spring session scope on the EntityManagerFactory

    Hi,
    In one of our projects we are trying to utilize the 2nd level cache of TopLink Essentials. The server code is using the Spring (2.0.7) and is deployed to a web container. We are using a Java client and serializes every object between the client and the server.
    When a client is started a lot of "static/common" data is read from the server. The first client started will therefor pay some extra performance cost, but additional clients should hopefully be able to perform better due to the cache. Most of the static data is accessed not using JPQL and should therefor not bypass the cache.
    If we configure the EntityManagerFactory using default Spring scoping (singleton) it seems like we are not able to utilize the cache. We can see from the log files that each time a client is started a lot of SQL is executed towards the database (Oracle).
      <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter">
          <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter">
            <property name="showSql" value="false" />
            <property name="generateDdl" value="$repository{toplink.generateDdl}" />
            <property name="database" value="$repository{toplink.database}" />
          </bean>
        </property>
        <property name="jpaProperties">
          <props>
            <prop key="toplink.weaving">static</prop>
            <prop key="toplink.logging.level">FINEST</prop>
          </props>
        </property>
      </bean>When we changes the scoping to spring session the behavior is very different. Then we can see that the first client generates a lot of SQL towards the database and pays a startup cost, while subsequently clients seems to be able to utilize the cache.
      <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" scope="session">
        <aop:scoped-proxy />
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter">
          <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter">
            <property name="showSql" value="false" />
            <property name="generateDdl" value="$repository{toplink.generateDdl}" />
            <property name="database" value="$repository{toplink.database}" />
          </bean>
        </property>
        <property name="jpaProperties">
          <props>
            <prop key="toplink.weaving">static</prop>
            <prop key="toplink.logging.level">FINEST</prop>
          </props>
        </property>
      </bean>Having read the documentation of the spring session scope I'm having a hard time explaining this behavior. As I understand it the EntityManagerFactory will be stored in the HTTP session resulting in a new EntityManagerFactory for each session. I cannot understand how this may result in that we are able to utilize the 2nd level cache? What are the relationship between the EntityManagerFactory and the 2nd level cache?
    Is this an accepted way of configuring the EntityManagerFactory or will there be a downside?
    I hope someone are able to explain this behavior for me:-)
    Best regards,
    Rune

    Hi Rune,
    To understand the shared cache behavior you actually need to understand more about what TopLink Essentials does than what Spring does. When a new factory is created, TopLink Essentials actually just proxies the server session with a factory instance, so the same server session is used. This is why you are seeing the same cache used across multiple factories of the same session.
    In the first case, if you are not using JPQL then what are you using to load the data and why are you thinking that it will not bypass the cache?
    Using a factory instance for each session is not what I would recommend doing as there are some additional costs associated with establishing a factory (even though the session already exists). The first way should be the correct way, I am just not sure what the circumstances are that are causing your cache to not be warmed. You may want to post more details about that so people can better help you out with that angle.
    -Mike

  • Toplink essentials overwhelming bug(s)

    Hello.
    I'm working on EJB3 project running on Glassfish application server that uses Toplink Essentials as persistance engine.
    In the project there is User entity and some entities inherited from User such as Operator, Vendor, Client, etc... And there is StoredMessage entity. StoredMessage has two attributes (sender, recepient) of User class.
    And the problem is: when trying to persist StoredMessage object via entity manager i'm getting an error like "Cannot persist detached object Operator"... but that is gibberish thing. The User objects are not detached (for test purposes I even merged them vie entity manage just befor StoredMessage persisting) and i'm not working with Operator object there, I'm working with User object, that's most interesting thing.
    I decided to make a temporary workaround and store sender and recepient's IDs int StoredMessage class insted of User object references... But i didn't want to change interfaces in my program, so I leaved old getters and setters for sender and recepient, annotated them transient and changed to get these User objects transparrently through entity menager (I know, that's not a good architectural solution).
    Afrer that Toplink become insane :) I got an error that java.util.Date property in my StoredMessage class is not annotated with a @Temporal, but in code everything was ok. I removed all the code related to that date field and after that I got another error: it said i have to annotate ID field with @Id, but it also was annotated correctly.
    When I'm setting sender and recepient fields to null everything works all right and entity manager persists my StoredMessage object with no problem.
    That bugs are very weird, I haven't seen anything like this... And i'm working on this project for two months, there are about 30 other entities with different relation types in the project and everything works all right and doesn't have any problem with entity manager. Today i've got the first bug.
    Does anybody seen something like this? Do you know how to fix it?
    There is another workaround in my mind, i can just use pure JDBC for StoredMessage objects persistance, but such solution has a number of disadvantages and I have no guarantee that such bugs won't happen with new entities in the project.

    Thank you for reply!
    Do sender and recipient use the same Foreign key? Do you have cascade persist set?Humm, yes, they both the same foreign key. Yes, i have "(cascade = {CascadeType.ALL})" if you mean that.
    Can you please post the relevant Portions of the java and annotations and I can take a closer look.Sure, http://lab37.com/xchng/javacode.zip -- here is archive with User entity, StoredMessage entity and just in case i put Operator (extends User) entity there.

  • Toplink Essentials JPA doesn't use GenerationType.IDENTITY

    Based on EJB 3 and JPA I want to store some entities (@Entity) in a database. For some of those entites the database auto increments the primary key. In these cases I defined a @TableGenerator and a @GeneratedValue using GenerationType.IDENTITY as strategy in order to get the primary key (@Id) updated after the entity has been persisted.
    Short example:
    @Entity
    @Table(name = "orders")
    public class POrder implements PEntity {
         @TableGenerator(name = "orderIdGenerator", initialValue = 0, allocationSize = 1)
         @Id
         @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "orderIdGenerator")
         @Column(name = "orderNumber", nullable = false)
         private Integer orderNumber;
    ...I am running the application on GlassFish. I added a corresponding JDBC resource to the server configuration, using the specific MySql driver interfaces.
    Persisting entities which doesn't use a TableGenerator works, but as soon as I try to persist an entity which should use a TableGenerator I am running in the following exception:
    beergame.server.exception.BeergameServerException: nested exception is: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.1 (Build b55-fcs (10/10/2008))): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'beergame3.sequence' doesn't exist
    Error Code: 1146
    Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
         bind => [1, roleIdGenerator]
    Query: DataModifyQuery()
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.1 (Build b55-fcs (10/10/2008))): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'beergame3.sequence' doesn't exist
    Error Code: 1146
    Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
         bind => [1, roleIdGenerator]
    Query: DataModifyQuery()
         at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:311)
         at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:654)
         at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:703)
         at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:492)
         at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:452)
         at oracle.toplink.essentials.internal.sessions.AbstractSession.executeCall(AbstractSession.java:690)
         at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
         at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:214)
         at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:257)
         at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:237)
         at oracle.toplink.essentials.queryframework.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:86)
         at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
         at oracle.toplink.essentials.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:1845)
         at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
         at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:924)
         at oracle.toplink.essentials.sequencing.QuerySequence.update(QuerySequence.java:344)
         at oracle.toplink.essentials.sequencing.QuerySequence.updateAndSelectSequence(QuerySequence.java:283)
         at oracle.toplink.essentials.sequencing.StandardSequence.getGeneratedVector(StandardSequence.java:96)
         at oracle.toplink.essentials.sequencing.Sequence.getGeneratedVector(Sequence.java:281)
         at oracle.toplink.essentials.internal.sequencing.SequencingManager$Preallocation_Transaction_NoAccessor_State.getNextValue(SequencingManager.java:420)
         at oracle.toplink.essentials.internal.sequencing.SequencingManager.getNextValue(SequencingManager.java:846)
         at oracle.toplink.essentials.internal.sequencing.ClientSessionSequencing.getNextValue(ClientSessionSequencing.java:110)
         at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:240)
         at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.assignSequenceNumber(UnitOfWorkImpl.java:355)
         at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist(UnitOfWorkImpl.java:3266)
         at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist(RepeatableWriteUnitOfWork.java:432)
         at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:3226)
         at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist(EntityManagerImpl.java:221)
         at com.sun.enterprise.util.EntityManagerWrapper.persist(EntityManagerWrapper.java:440)
         at beergame.server.model.trans.impl.TExtensionOfPEntityImpl.persist(TExtensionOfPEntityImpl.java:130)
         at beergame.server.model.trans.impl.TRoleImpl.<init>(TRoleImpl.java:61)
         at beergame.server.logic.trans.impl.GameLogicImpl.assignUserToValueChainLevel(GameLogicImpl.java:81)
         at beergame.server.logic.remote.impl.UserSessionBean.createGame(UserSessionBean.java:65)
    I wonder why a sequence table has to be update whereas IDENTITY is defined as strategy. I tried also AUTO as strategy but it doesn' matter, the result is the same.
    I read several posts in forums, but couldn't find a solution. So I still have no idea how to get IDENTITY used as strategy. Any one of you does?
    My configuration:
    IDE: Eclipse 3.4.0
    Server: GlassFish V2 Java EE 5
    JPA Implementation: Toplink Essentials v2.1-b55
    JPA driver: oracle.toplink.essentials.PersistenceProvider
    Database: MySQL 5.0.51a
    JDBC driver: mysql-connector-java-5.1.5

    I did it. I must admit, I was a little bit confused by the annotation TableGenerator. It is not responsible for generating ids of a table at all but only in conjunction with a table which should provide ids.
    After I removed @TableGenerator and also the corresponding reference within @GeneratedValue the persistence works as expected. Now the code looks like this:
    @Entity
    @Table(name = "orders")
    public class POrder implements PEntity {
         @Id
         @GeneratedValue(strategy = GenerationType.IDENTITY)
         @Column(name = "orderNumber", nullable = false)
         private Integer orderNumber;
    ...Edited by: TomCat78 on Oct 12, 2008 3:38 PM

  • TopLink essentials: extra where clause for one to many relationship?

    We have a lot of tables that contain "historic" records. Those are marked by a column "historic" holding a value "Y". Sometimes we are not interested in historic values. For example in the next case:
    @Entity
    @Table(name="ART")
    public class Article {
        @OneToMany(mappedBy="article", cascade=CascadeType.ALL, fetch=FetchType.LAZY)
        private Collection<ArticleStats> arcItems;
        public Collection<ArticleStats> getArticleStats() {
            return arcItems;
    }One article can have multiple "stats". We are in this case only interested in the "stats" of this article that are not historic. In SQL terms, I would like to add an extra where clause: "WHERE historic = 'N'".
    Of course inheritance (with discriminators) is an option, but I don't prefer that. We have a lot of relationships like this and using inheritance would mean we have to add a lot of extra classes. Is there a way to add an extra where clause to the query that is used to retrieve all the stats records related tot my Article?
    We use TopLink essentials with an IBM AS/400 database.

    The JPA Spec does not handle this case, but TopLink Essentials does. You will need to customize your TopLink descriptor using a DescriptorCustomizer. You can set your DescriptorCustomizer in your persistence.xml using the "toplink.descriptor.customizer.<entity-name>" property set to the class name "<package>.<class>" of your customizer class.
    The customizer would look something like:
    public class MyCustomizer implements DescriptorCustomizer {
    public void customize(ClassDescriptor descriptor) {
    OneToManyMapping mapping = (OneToManyMapping )descriptor.getMappingForAttributeName("arcItems");
    ExpressionBuilder builder = new ExpressionBuilder();
    mapping.setSelectionCriteria(builder.getField("STAT.ART_ID").equal(builder.getParameter("ART.ID").and(builder.getField("HISTORY").equal("N")));
    If you never wanted historical records you could also add this expression to your descriptor's additionalJoinExpression.
    James Sutherland

  • Toplink Essentials creates not usable select statement

    My problem is the following:
    I have the following NamedQuery statement in an JPA Entity Class:
    @NamedQuery(name = "Leasingteilvertrag.findSearch",
    query = "select distinct o " +
    " from Leasingteilvertrag o " +
    " left outer join o.sachbearbeiterList s " +
    " where (:wtvStatusBearb1 is null or :wtvStatusBearb2 = -1 or o.wtvStatusBearb =
    :wtvStatusBearb3)" +
    " and (:wtvStatusVerwert1 is null or :wtvStatusVerwert2 = -1 or o.wtvStatusVerwert = :wtvStatusVerwert3)" +
    " and (:wtvAdressNr1 is null or :wtvAdressNr2 = -1 or o.wtvAdressNr =
    :wtvAdressNr3)" +
    " and (:wtvEingangsdatum1 is null or o.wtvEingangsdatum >= :wtvEingangsdatum2)" +
    " and (:wtvEingangsdatumBis1 is null or o.wtvEingangsdatum <= :wtvEingangsdatumBis2)"
    +
    " and (:wtvLlvNr1 is null or o.wtvLlvNr = :wtvLlvNr2)" +
    " and (:wtvFirma1 is null or o.wtvFirma = :wtvFirma2)" +
    " and (:wsbId1 is null or :wsbId2 = -1 or s.wsbSbId = :wsbId3)")
    Oracle Toplink translates this (according to to opmn log of the Application Server)
    to:
    SELECT DISTINCT t0.WTV_ID, t0.WTV_SL_PLUS_KNZ, t0.WTV_ABGESCHLOSSENDATUM, t0.WTV_SL_TECHNIK_DATE, t0.WTV_ADRESS_POOL, t0.WTV_SL_TECHNIK_KNZ,
    t0.WTV_AKTENZEICHEN_RA, t0.WTV_SONDERAFA_OBJEKTE_AKTUELL,
    t0.WTV_ANZAHLRUECKSTAENDIGERRATEN, t0.WTV_SONDERAFA_OBJEKTE_GEBUCHT,
    t0.WTV_BANKAUSKUNFT_KNZ, t0.WTV_STATUS_BEARB, t0.WTV_EINGANGSDATUM,
    t0.WTV_STATUS_BEARB_DATUM, t0.WTV_EINSCHAETZUNG_BONI, t0.WTV_STATUS_VERWERT,
    t0.WTV_EWB_DATUM_ERFASSUNG, t0.WTV_STATUS_VERWERT_DATUM, t0.WTV_EWB_GEBUCHT,
    t0.WTV_STATUS_FREIGABE, t0.WTV_EWB_SB_ERFASSUNG, t0.WTV_STATUS_FREIGABE_DATUM,
    t0.WTV_FIRMA, t0.WTV_VERBLEIB_AKTE, t0.WTV_WAEHRUNG_AUSFALL,
    t0.WTV_KUENDIGUNGSFORDERUNG, t0.WTV_WAEHRUNG_EWB, t0.WTV_LLV_NR,
    t0.WTV_WAEHRUNG_RUECKST_ANR, t0.WTV_LTV_NR, t0.WTV_WAEHRUNG_SONDERAFA_OBJEKTE,
    t0.WTV_PROZESSKOSTEN_RISIKO, t0.WTV_WAE_EINSCHAETZUNG_BONI,
    t0.WTV_RUECKST_ANRECHNUNG_GEBUCHT, t0.WTV_WAE_KUENDIGUNGSFORDERUNG,
    t0.WTV_SL_KASKO_DATE, t0.WTV_WIEDERGESUNDUNGSDATUM, t0.WTV_SL_PLUS_DATE,
    t0.WTV_ABGESCHLOSSEN_KNZ, t0.WTV_AKTENZEICHEN_FAV, t0.WTV_TEILRISIKO_KNZ,
    t0.WTV_AUSFALL, t0.WTV_BETRUG_KNZ, t0.WTV_EINGANGSDATUM_ALT,
    t0.WTV_CHANGE_USER, t0.WTV_EWB_DATUM_FREIGABE, t0.WTV_CHANGE_DATE,
    t0.WTV_EWB_SB_FREIGABE, t0.WTV_FREIGABE_KOMMENTAR, t0.WTV_KUENDIGUNGSDATUM,
    t0.WTV_ADRESS_NR, t0.WTV_ALTFALL_KNZ, t0.WTV_OPERATIONELLES_RISIKO,
    t0.WTV_BEMERKUNG, t0.WTV_SACHSTAND, t0.WTV_EWB_AKTUELL,
    t0.WTV_LLV_NR_UMFINANZIERUNG, t0.WTV_EWB_KORREKTUR, t0.WTV_SL_KASKO_KNZ,
    t0.WTV_FIRMA_UMFINANZIERUNG, t0.WTV_RUECKST_ANRECHNUNG_AKTUELL,
    t0.WTV_KUENDIGUNGSFORDERUNG_ALT, t0.WTV_LEASINGVERTRAG_ID,
    t0.WTV_RUECKST_ANRECHNUNG_BUC_ID, t0.WTV_EWB_BUC_ID,
    t0.WTV_SONDERAFA_OBJEKTE_BUC_ID FROM VWDB_LEASINGTEILVERTRAG t0,
    VWDB_LEASINGTEILVERTRAG t2, VWDB_SACHBEARBEITER t1 WHERE (((((((((((? IS NULL)
    OR (? = (? - ?))) OR (t0.WTV_STATUS_BEARB = ?)) AND (((? IS NULL) OR (? = (? -
    ?))) OR (t0.WTV_STATUS_VERWERT = ?))) AND (((? IS NULL) OR (? = (? - ?))) OR
    (t0.WTV_ADRESS_NR = ?))) AND ((? IS NULL) OR (t0.WTV_EINGANGSDATUM > ?))) AND
    ((? IS NULL) OR (t0.WTV_EINGANGSDATUM < ?))) AND ((? IS NULL) OR (t0.WTV_LLV_NR
    = ?))) AND ((? IS NULL) OR (t0.WTV_FIRMA = ?))) AND (((? IS NULL) OR (? = (? -
    ?))) OR (t1.WSB_SB_ID = ?))) AND (t1.WSB_LTV_ID (+) = t0.WTV_ID))
    The Problem is the "VWDB_LEASINGTEILVERTRAG t2" entry in the FROM clause of the generated select statement. This causes the select to generate the cartesian product.
    Has anyone had such a problem before? How can this be solved?

    Hello,
    I have exactly the same problem (with a simpler query though). I'm running my webapp on a GlassFish V2 (build b09d-fcs), Toplink Essentials JPA impl. and a MySQL 6.0.4 database server.
    I'm trying to run the following JPQL query: select f from Foo f where (1=1) and f.title = :title
    After having set persistence log levels to FINE, the following SQL is displayed:
    select t0.XXX, t0.YYY from Foo t0, Foo t1 where ((?=?) and (t0.title= ?))
    bind => [1, 1, Bar]
    (1 = 1) is used because of dynamic query generation (application code)
    The problem is that the additional from clause is generating a cartesian product on my Foo table, which causes many duplicated results to be returned.
    I have simplified the select part of the query but the actual query is of the same kind: no join, only 1 entity, no inheritance, a single N:1 lazy-initialized entity (*Foo-1FooParent). The only "exotic" facet of my Foo mapping is the use of an @Enumerated column.
    Is it the expected behavior?
    -Titix

Maybe you are looking for