Toplink JPA LAZY loading in Java SE works without javaagent?

hi there,
I tought that mappings like
@JoinColumn(name = "join_col_name")
@ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.LAZY)
private RelatedObject relObj;
with TopLink JPA in Java SE environment works ONLY with the
-javaagent:toplink-essentials-agent.jar
JVM parameter?
the strange thing is: I did 2 test runs, with and without the java agent parameter. I also could see that in the first case the weaver is working, in the second the property "toplink.weaving=false" is printed to the console BUT if I access the LAZY mapped attribute of the object instance it works in both cases - I expected a NullPointerEx. in the case without the javaagent.
Is there anything I missed?
Hans

Chris,
thank for for the tip about verifying lazy or eager fetching. The results are interesting - or better: confusing - to me:
I have built a test project with 3 entities:
Entity A hast @OneToMany to Entity B and
Entity B has ManyToONe to Entity C
A <-- B --> C
ALL relations are marked with FetchType.LAZY in all directions.
When I simply run the test project via main()-method out of eclipse, WITHTOUT specifycing a -javaagent parameter in the run dialog, I can confirm using your test case that the realtion IS LAZILY FETCHED.
So, I do not really know how this should work without the javaagent.
You mentioned statically weaved classed - is this the default case when no agent is present, how is it done? Toplink logging says that weaving is NOT active:
ServerSession(16821027)--Thread(Thread[main,5,main])--property=toplink.weaving; value=false
so how can the lazy loading work then?
regards,
Hans

Similar Messages

  • JPA - lazy loading for LOB field

    Hi all,
    JPA 1.0 specification mandates that all JPA-compliant implementation support lazy loading for certain kind of entity field.
    For LOB fields lazy loading is OPTIONAL.
    I am experiencing odd runtime behaviors on my custom software which would point to this feature not being supported.
    Can anyone please tell me if SAP JPA 1.0 implementation on NW CE 711 implements this feature or not?
    Thanks in advance
    Regards
    Vincenzo

    Hi Vincenco,
    I am sure that this is the same as with single-valued relationships (@OneToOne, @ManyToOne): Lazy loading would require bytecode manipulation/generation, so SAP JPA does not support it in 7.20 (and of course not in 7.11)
    See tulsi jiddimani's elaborate answer here: Re: JPA: Documentation on LazyLoad.
    In 7.30 enhancements, you really can find lazy loading support for single-valued relationships with getReference.
    http://help.sap.com/saphelp_nw73/helpdata/en/68/f676ef36094f4381467a308a98fd2a/content.htm
    but @Lob and @Basic is not mentioned.
    If you need lazy loading in 7.11, you have two alternatives:
    1. Put the Lob fields into separate entities, work around the missing feature in SAP JPA with ugly @OneToMany - Relations
    2. Use another persistence provider like EclipseLink, read Sabine Heider's blogs about integrattion of EclipseLink in SAP NetWeaver and static bytecode weaving for lazy loading. /people/sabine.heider/blog
    Regards
    Rolf

  • JPA lazy loading with Firebirdsql

    I'm trying to use FetchType.Lazy in @OneToOne associations, with a firebirdsql database.
    Toplink JPA generates the sql query as follow:
    SELECT FIELD1, FIELD2, _TOPLINK_FIELD3_VH, ... FROM TABLE.....
    This select gets this error msg:
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: org.firebirdsql.jdbc.FBSQLException: Exception. nullError Code: 0
    (it can't find the TOPLINKFIELD3_VH field)
    Is this an issue related to firebirdsql support on Toplink?
    Or is it a issue related to firebirdsql JDBC driver/database?

    Don't double post. I've removed the thread you started 3 hrs 16 minutes after this one with the identically same question.
    db

  • Equals and lazy loading

    Hi all,
    We have an application in which we use lazy loading on our client, so we can't be sure that both objects have the same objects reference loaded already. While implementing the equals method I came to the problem if it makes sense to compare the lazy loaded objects as well, because this might lead to a very deep object comparison through the whole object tree which might be very unperformant if I load this references on demand. Otherwise not comparing the references might be an incomplete comparision of these objects and makes the usage of the equals method very difficult.
    Has anyone experience using the equals method with lazy loading?
    Thanks in advance
    Marco

    Okay - here comes a little more detail about our architecture to give you a deeper understanding. Currently we are working with EJB3 / JBoss environment but our intention is to encapsulate this through a DAO-layer. Anyways we have special object-dependencies as per example a customer has it�s orders. So in my understanding a customer with the an address, a name etc. with NO orders is not the same as a customer with the same address and the same name and let�s say 2 orders. So I can stick with comparing simply the name and the address, but this wouldn�t give you an exact comparison.
    The other way would be to compare the orders as well, but what if the orders have a number of invoices behind them. The conclusion would be, that I�d have to compare them as well. Additionally I have the problem, that I have totally equal customers with the same number of orders and invoices, but the first one has a null-value in its orders, because they have not been loaded from database yet and the other one has. So my technique with comparing the lazy-loaded references would not work here. A complete loading of all references for a comparison cannot be the solution here either.
    So it is hard to say if they are I/O intensive. Worst case would be, that we have to load the complete object-tree for comparison from database and send them between client and server (jboss). This is part of our question? Should this be the consequence of lazy loading or is it best pratice to stick with the local attributes and let the client do the work, so that he has to work through the whole object-tree if he wants to know the exact equality.
    Does this give you a more detailled view of our question? I guess I am not the first to deal with this problem, so I�d like to share your experiences with you about what is "wise" to do.
    Thanks for your help
    Marco

  • It doesn�t work lazy loading with remote client (toplink)

    I am trying to use lazy loading in a @ManyToOne field but I get an exception. I have been reading in some oracle tutorials that it's necesary use -javaagent:.../lib/toplink-essentials-agent.jar for that it works because this argument activate dynamic weaving in JavaSE. I have put this command line argument javaagent but it doesn't work. Why? Can I have to do another thing? I have done a lot of tests in base to comments read in another forums but I only obtains an exception.
    Caused by: java.io.IOException: Mismatched serialization UIDs
    NOTE: The server use toplink and the remote client query the entitties through a session bean of the server. Besides, I am using Glassfish (Sun application server and toplink).
    Thanks in advance.
    hayken

    At first, thank you for your reply.
    I know that I haven´t explained the problem too well. I have a stateless bean with one remote method that execute a query an returns an entity like this
    @Entity
    public class ModuloEntity extends Serializable
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long idModulo;
    private String nombre;
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="IdProyecto")
    private ProyectoEntity proyecto;
    The remote client invoke this method and in that moment I get this exception.
    21-may-2007 18:55:48 com.sun.corba.ee.impl.encoding.CDRInputStream_1_0 read_value
    ADVERTENCIA: "IOP00810211: (MARSHAL) Exception from readValue on ValueHandler in CDRInputStream"
    org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 211 completed: Maybe
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.valuehandlerReadException(ORBUtilSystemException.java:7053)
    Caused by: java.io.IOException: Mismatched serialization UIDs : Source (Rep. IDRMI:com.syskonic.gesplan.entities.ModuloEntity:6D06A8C14D488FFF:8E6FC8687EA9E512) = 8E6FC8687EA9E512 whereas Target (Rep. ID RMI:com.syskonic.gesplan.entities.ModuloEntity:1C6925798CDFD3DF:3455DBF4457AE337) = 3455DBF4457AE337
    at com.sun.corba.ee.impl.util.RepositoryId.useFullValueDescription(RepositoryId.java:573)
    If I look the server log, I can see that the call has not been produced, it doesn´t show any exception. It looks that the object managed by the server and the remote client aren´t the same and the corba service doesn´t work when remote client call session method. If I change the ModuloEntity and remove the fetch attribute then all this process executes correctly. The problem is in this attribute.
    NOTE: I am using the javaagent command line argument.
    Hayken

  • Toplink.weaving=true gives PersistenceException; for Lazy Loading config.

    I could use some help configuring my persistence.xml file, trying to make sure Lazy loading is configured properly. What I see in the logs normally is that Toplink defaults to Eager fetching on my JPA objects. So according to
    http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/toplink-jpa-extensions.html
    I need to set toplink.weaving=true in persistence.xml, however I get the Exception below when I make the call to get the EntityManager for the first time.
    I'm using OC4J standalone 10.1.3.3 with JDK 1.5.0_13 and the latest Toplink (as you can see in the stack trace below). An excerpt from my persistence.xml is below that.
    Caused by: Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
    Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: xyx-dal-webservice.root:0.0.0
    Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28020] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exc
    eptions.EntityManagerSetupException
    Exception Description: Value [true] for the property [toplink.weaving] is incorrect when global instrumentation is null, value should either be null or false. at oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:143)
    at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:169)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:59)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
    at gov.dhs.visit.ident.dal.jpa.entity.cvt.util.EntityManagerHelper.<clinit>(EntityManagerHelper.java:20)
    ... 43 more
    Caused by: javax.persistence.PersistenceException: Exception [TOPLINK-28020] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.E
    ntityManagerSetupException
    Exception Description: Value [true] for the property [toplink.weaving] is incorrect when global instrumentation is null, value should either be null or false.
    at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.callPredeploy(JavaSECMPInitializer.java:151)
    at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initPersistenceUnits(JavaSECMPInitializer.java:239)
    at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:255)
    at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:155)
    ... 46 more
    Caused by: Exception [TOPLINK-28020] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: Value [true] for the property [toplink.weaving] is incorrect when global instrumentation is null, value should either be null or false.
    at oracle.toplink.essentials.exceptions.EntityManagerSetupException.wrongWeavingPropertyValue(EntityManagerSetupException.java:244)
    ... 50 more
    SEVERE: Caught exception while handling request: oracle.oc4j.rmi.OracleRemoteException: java.lang.ExceptionInInitializerError; nested exception is:
    java.lang.ExceptionInInitializerError oracle.oc4j.rmi.OracleRemoteException: java.lang.ExceptionInInitializerError; nested exception is:
    java.lang.ExceptionInInitializerError
    persistence.xml
      <persistence-unit name="PUName" transaction-type="JTA">
         <provider>oracle.toplink.essentials.PersistenceProvider</provider>
              <jta-data-source>jdbc/mydb</jta-data-source>
    <class>....a whole lotta JPA classes...</class>
        <properties>
             <property name="toplink.logging.level" value="FINE" />
             <property name="toplink.logging.timestamp" value="true"/>
               <property name="toplink.target-database" value="Oracle"/>
               <property name="toplink.target-server" value="OC4J_10_1_3" />
               <property name="toplink.weaving" value="true"/>
                    <property name="toplink.cache.shared.default" value="false"/>
        </properties>
      </persistence-unit>

    This error confuses me...
    Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
    Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@11b86e7
    Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28020] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: Value [true] for the property [toplink.weaving] is incorrect when global instrumentation is null, value should either be null or false.
         at oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:143)
         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:169)
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:110)I'm using TopLink from regular ol' Java SE (not container managed environment).
    http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/toplink-jpa-extensions.html gives some hints, though, especially if you're operating outside of a container (seems like you gotta weave yourself). See http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/toplink-jpa-extensions.html#LazyLoading
    Seems the command-line arg "-javaagent:toplink-essentials-agent.jar" is critical if you're running outside a container.

  • Java and lazy loading

    Hello all!
    I have three question regarding lazy loading:
    Question one: Can it be said that java works by lazy loading by default?
    Question two: What is the opposite of lazy loading?
    Question three: How can I change this default behavior to the opposite of lazy loading?
    Thanks in advance,
    Julien.

    1. Yes.
    2. Eager loading.
    3. You can't. You can get a half-decent approximation using a suitable classloader, though. After defining your class, you parse the string table and load the classes referred to therein. BCEL may useful for the parsing.

  • Need help with Java SE TopLink JPA project

    I'd like to ultimately run an Oracle stored procedure (connecting to Oracle 10g DB) in my Java SE program. I want to use TopLink JPA (11g) and if possible, use sessions to manage things - i.e. I want to run a stored procedure (that doesn't return anything), then run a native query. Does anyone have a good example of this type of configuration?
    I've been able to get it working with plain ol' JPA via TopLink - i.e. my persistence.xml is fine. Obviously, JPA doesn't define stored procedures, so I need to set it up to use stored procedures. I tried setting up my sessions.xml file - I think it's OK. However, I think my project.xml file is incorrect - and I don't think I even really understand it. But I want a project.xml that is very simple - does anyone have a simple, bare-bones project.xml example. All I plan to do is run the occasional stored procedure and run native queries (for now).

    If all you want to do is create extra stored procedure queries then you might want to consider just creating a customizer and adding some queries there. Then you won't actually need to create a project at all.
    Use the toplink.session.customizer property described at:
    http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/toplink-jpa-extensions.html
    and then add some queries to your session. To make it even easier, then just define your queries in JPA, and override the call in your customizer. For example, if you defined a JPA named query called "Employee.executeStoredProc" then in your customizer method you could have something like:
    public void customize(Session session) {
    DatabaseQuery query = session.getQuery(“Employee.executeStoredProc”);
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("employee_stored_proc");
    query.setCall(call);
    Then when you call your JPA query the stored proc will run.

  • It seems you cannot clone objects with attributes using lazy loading in JPA

    I have an entity with an attribute using lazy loading:
    @Entity
    public class B {
    @ManyToOne(fetch=FetchType.LAZY)
    private A a;
    @Entity
    public class A {
    Assume the following code:
    A a1 = new A();
    A a2 = new A();
    B b1 = EntityManager.find(B.class, ...);
    b1.setA(a1);
    B b2 = b1.clone();
    b2.setA(a2);
    Now with lazy loading enabled I get b1.getA() == a2 instead of b1.getA() == a1. Moreover, the debugger displays the same value holder in b1 and b2 for the attribute a. It appears as if cloning does not make a (deep) copy of the value holder managing the attribute a.
    How can I create a copy b2 of b1, such that the value holder managing a in b1 is a different object as the value holder managing a in b2?
    Thanks, Thomas.

    I have filed a bug to have this addressed in Oracle TopLink 11gR1. I would recommend you file a bug against TopLink Essentials in GlassFish or if you have a support contract report the issue to metalink to have the issue resolved.
    If this is urgent I did try fixing the issue with a small helper method using some reflection. This method is simplified through its throwing of Exception. If you wish to use something like this I would recommend proper error handling.
         * Helper method for cloning an entity and fixing the woven value-holders to
         * complete a proper shallow cloning.
        public static Employee clone(Employee entity) throws Exception {
           Employee clone = entity.clone();
           // Now fix the cloned ValueHolder references
           Field[] fields = entity.getClass().getDeclaredFields();
           for (int index = 0; index < fields.length; index++) {
               Field field = fields[index];
               if (field.getName().startsWith("_toplink_")) {
                   field.setAccessible(true);
                   ValueHolderInterface vhi = (ValueHolderInterface)field.get(entity);
                   Object value = vhi.isInstantiated() ? vhi.getValue() : null;
                   field.set(clone, new ValueHolder(value));
           return clone;
        }Doug

  • Lazy loading differences Toplink vs. Hibernate - plz. explain

    I'm in the process of evaluating both Toplink and hibernate as potential ORM framework to use for a project I'm currently involved in.
    My question is about how Toplink resolves lazily loaded associations. In hibernate I have to perform a query inside a transactional context boundary, like:
    Session s = SessionFactory.getSession();
    s.beginTransaction();
    ... your query logic here
    s.getTransaction().commit();When the query involves associations which are declared as lazily loadable, trying to invoke these associations after the transaction boundary has been closed, results in an exception. This differs from Toplink (my JUnit testcase breaks for Hibernate if I set the DAOFactory to return hibernate enabled DAO's) and I'm wondering why?
    I'm guessing this has something to do with how Toplink manages its clientsession, but would like to get some confirmation about this. It looks like as-long as the thread of execution is running I can resolve associations using Toplink, but not when I use Hibernate.
    This brings me to yet another question - what's considered best practices in Toplink regarding session disposal. Should I do something myself, or let the garbage collector take care of it?

    I'm not too sure here, but I think it's because TopLink has a "long running" ServerSession. When you do lazy initialization outside a clientsession it is for read only purposes and it will use the centrally managed ServerSession (and cache). I'm still trying to figure out the exact relationships here, som I'm not too sure. :) Hibernate does not have a centrally shared cache, and will not be able to instantiate objects if the session is closed (for each session, objects are instantiated from it's data cache).
    As for handling resources and closing/opening, use the Spring/TopLink integration. It will handle it for you and give you heaps of convenience methods that uses some clever tricks to decide if it should fetch objects with Session or UnitOfWork. It will also do some good Exception handling built into Spring.

  • Lazy loading loads eager anyway ?

    Hello,
    I read in some articles and books that the lazy loading in EJB 3.0 is just a hint, in the sence that the persistence manager could decide to load eager, even if lazy configured.
    Is this correct, or will the default lazy loading always only fetch when asked ?
    C.

    This is true in the JPA Spec, i.e. meaning that supporting lazy loading is "optional" not required by the JPA Spec.
    However TopLink does support lazy loading. By default any @OneToMany or @ManyToMany mappings are lazy and will not be fetched until accessed. By default in the JPA Spec @OneToOne and @ManyToOne are not lazy, but if you set them to be lazy then TopLink will also support this, as long as you enable weaving (weaving is not require for @ToManys). I would recommend you always make your @OneToOne and @ManyToOne lazy. Weaving in TopLink can be enable either through using the TopLink agent when launching your Java VM, or is used automatically in OracleAS or Glassfish, or through using the TopLink static weaving ant task.
    In TopLink Essentials lazy on @Basic mappings is not supported, however this will be supported in TopLink 11g.

  • Couldn't persist OneToMany JoinColumn/JoinTable (Unidir) using TopLink JPA

    Hi All,
    I am having a lot of difficulty deploying a OneToMany Unidirectional (Zipcode) record which consist of multiple Zipnames using TopLink on Glassfish v2r2, JDK1.6.0_06, MySQL 5.0, Netbeans 6.1 and Windows XP platform.
    Below are the relevant EJBs snippets:
    Zipcode class
    @Entity
    @Table(name="ZIPCODE")
    public class Zipcode implements Serializable {
    @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
    @JoinColumn(name="ZIPCODE_ID")    
                 or
        @JoinTable(name="ZIPCODE_ZIPNAME",          
                   joinColumns={@JoinColumn(name="ZIPCODE_ID")},
                   inverseJoinColumns={@JoinColumn(name="ZIPNAME_ID")})
        private Collection<Zipname> zipnames = new ArrayList<Zipname>();
        public Collection<Zipname> getNames()
         return zipnames;
        public void setZipnames(Collection<Zipname> zipnames)
         this.zipnames = zipnames;
    Zipname class does not maintain relationship back to Zipcode.
    public class ZipcodeApplicationClient {
    @PersistenceContext(unitName="GeographicalDB-PU")
    private static EntityManager manager;
        public ZipcodeApplicationClient() {
        public static void main(String[] args) {
            try {
                Zipcode zipcode_1 = new Zipcode();
                zipcode_1.setcode(9001);
                Zipname zipname_1 = new Zipname();
                zipname_1.setName("Harbour Cove");
                zipcode_1.getNames().add(zipname_1);
                // Can add one Zipname record with JoinTable but not JoinColumn
                Zipname zipname_2 = new Zipname();
                zipname_2.setName("Wonderland");
                zipcode_1.getNames().add(zipname_2);
                manager.persist(zipcode_1);   // line 45
    The same deployment error message below was generated from both JoinColumn and JoinTable methods:
    run-deploy:
    run-display-browser:
    run-ac:
    Copying 1 file to C:\Documents and Settings\Jack\GeographicalBean\dist
    Caught an unexpected exception!
    java.lang.NullPointerException
            at client.ZipcodeApplicationClient.main(ZipcodeApplicationClient.java:45)
            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:597)
            at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
            at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
            at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
            at com.sun.enterprise.appclient.Main.main(Main.java:200)
    run-InvestmentBean-app-client:The JoinColumn method would not work for one Zipname record. On the other hand, JoinTable approach would allow us to add a single Zipname record without error out.
    Q1. Can you confirm whether TopLink JPA 1.0 (Glassfish v2r2) support OneToMany JoinColumn Unidirectional at all?
    Q2. Does TopLink JPA 1.0 (Glassfish v2r2) support OneToMany JoinTable Unidirectional? If so, what is the cause of this issue? Otherwise, please make appropriate recommendation steps to take.
    This question has been posted on http://forums.sun.com/thread.jspa?threadID=5330670&tstart=0 and http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=78&t=004489&p=1 earlier in the hope a quicker response.
    Your guidance would be very much appreciated.
    Many thanks,
    Jack

    Hi,
    Below are some more error output from the OneToMany JoinTable Unidirectional approach:
    pre-run-deploy:
    Initial deploying InvestmentBean to C:\Documents and Settings\abc\InvestmentBean\dist\gfdeploy
    Completed initial distribution of InvestmentBean
    Start registering the project's server resources
    Finished registering server resources
    moduleID=InvestmentBean
    deployment started : 0%
    deployment finished : 100%
    Deploying application in domain completed successfully
    Trying to create reference for application in target server completed successfully
    Trying to start application in target server completed successfully
    WARNING:
    JDO76614: Deployment encountered SQL Exceptions:
    JDO76609: Got SQLException executing statement "CREATE TABLE ZIPCODE (ID INTEGER NOT NULL, DIALING_CODE VARCHAR(255), TIME_ZONE VARCHAR(255), CODE INTEGER, NEAREST_AIRPORT VARCHAR(255), LONGITUDE VARCHAR(255), NEAREST_TRAIN_STATION VARCHAR(255), NEAREST_URBAN_CENTRE VARCHAR(255), HOTELS VARCHAR(255), LATITUDE VARCHAR(255), NEARBY_FEATURES VARCHAR(255), COUNCIL VARCHAR(255), LOCALITY VARCHAR(255), PRIMARY KEY (ID))": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'zipcode' already exists
    JDO76609: Got SQLException executing statement "CREATE TABLE ZIPCODE_ZIPNAME (ZIPCODE_ID INTEGER NOT NULL, ZIPNAME_ID INTEGER NOT NULL, PRIMARY KEY (ZIPCODE_ID, ZIPNAME_ID))": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'zipcode_zipname' already exists
    JDO76609: Got SQLException executing statement "CREATE TABLE ZIPNAME (ID INTEGER NOT NULL, NAME VARCHAR(255), PRIMARY KEY (ID))": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'zipname' already exists
    JDO76609: Got SQLException executing statement "ALTER TABLE ZIPCODE_ZIPNAME ADD CONSTRAINT FK_ZIPCODE_ZIPNAME_ZIPCODE_ID FOREIGN KEY (ZIPCODE_ID) REFERENCES ZIPCODE (ID)": java.sql.SQLException: Can't create table '.\geographicaldb\#sql-434_4.frm' (errno: 121)
    JDO76609: Got SQLException executing statement "ALTER TABLE ZIPCODE_ZIPNAME ADD CONSTRAINT FK_ZIPCODE_ZIPNAME_ZIPNAME_ID FOREIGN KEY (ZIPNAME_ID) REFERENCES ZIPNAME (ID)": java.sql.SQLException: Can't create table '.\geographicaldb\#sql-434_4.frm' (errno: 121)Enable of InvestmentBean in target server completed successfully
    Enable of application in all targets completed successfully
    All operations completed successfully
    post-run-deploy:
    run-deploy:
    run-display-browser:
    run-ac:
    Copying 1 file to C:\Documents and Settings\Jack\GeographicalBean\dist
    Caught an unexpected exception!
    java.lang.NullPointerException
    at client.ZipcodeApplicationClient.main(ZipcodeApplicationClient.java:45)
    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:597)
    at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
    at com.sun.enterprise.appclient.Main.main(Main.java:200)
    run-GeographicalBean-app-client:
    run:
    I would like to correct an earleir comment where I stated that this method did work when adding a single Zipname record. This is no true.
    Thanks,
    Jack

  • Facing problem with lazy loading in ejb3.0

    The following error is coming up when i try to access the collection in the entity entity bean. i am using entitymanager.find() to retrieve the entity. intial set of values are coming fine but when try to access the collection in the entity the error is coming up. one solution is to make the fetch type=eager. but can we do lazy loading with out any problem. the following is the error. kindly help me in this. do i need to do anything extra that mean have to add any annotations or anything.
    org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.lucid.erp.entities.EmployeeDTO.addresses, no session or session was closed
         at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
         at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
         at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
         at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
         at org.hibernate.collection.PersistentBag.get(PersistentBag.java:422)
         at com.lucidlabs.erp.actions.EmployeeAction.view(EmployeeAction.java:20)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
         at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
         at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
         at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
         at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
         at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:184)
         at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         at

    this is transactions 101 material. Do you know about transactions and how they work? Do you know about managed entities?
    The problem you are having is that the addresses are accessed outside of the transaction in which the entity was fetched. That means there is no more database session and thus the lazy fetch cannot work. If you really need the addresses, you can at least force fetch them by calling getAddresses().size() right after you fetch the entity from the database; assuming that the transaction is still active at that point.

  • Lazy Loading, Muse, and Scripts

    Hi, I'm trying to integrate Lazy loading with Muse in a Web Site.
    I would like know if anyone has a better workflow...
    So, first I uploaded to the server the "lazy loading content"
    http://dandalo.net/teste/lazy-patricia/lazy-pat.html
    Then, in Muse, I inserted the html from the page source that I had uploaded.
    http://dandalo.net/teste/export-muse/detalhes-old.html
    But it didn't work... : (
    So... 
    I have started looking at the html code that Muse created and fond this special phrase...    <!-- Other scripts -->
    Then, I tried this:
    Coping the scripts from the "lazy loading content" page and pasting it after this special line:
    http://dandalo.net/teste/export-muse/detalhes.html
    And it Worked !!!
    PS: The java scrips should be in root folder, not in the Scripts folder that Muse created
    Does anyone have any tip or workflow not to have to edit the html file to add these script lines?

    Hi
    Do you have the link to the "lazy loading content"?
    I can't find a proper way to do it.
    Thanks

  • Toplink JPA with Coherence deployment to Weblogic 10.3

    Hi,
    I have created an EJB application using Toplink JPA and Coherence. I would like to deploy this application to Weblogic 10.3.
    During the startup of Weblogic I have specified the Java option as
    -Dtangosol.coherence.cacheconfig=D:/JDEV_11g/jdeveloper/jdev/mywork/CoherenceApp/CoherenceProject/src/META-INF/coherence-cache-config.xml.
    Persistence.xml and coherence-cache-config.xml are palced inside the jar file.
    When I execute the ejb client program, during the method call, I can see that coherence is started but it uses the cache-config from the coherence.jar file instaed of the value I have set during startup. How can I make weblogic use my cache-config.xml? I have included the log file entries from server:
    [EL Finest]: 2009.04.17 05:33:48.625--UnitOfWork(1777337)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadObjectQuery(coherenceproject.MetadataType)
    2009-04-17 05:33:54.547/258.954 Oracle Coherence 3.4.2/411 <Info> (thread=[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Loaded operational configuration from resource "zip:D:/JDEV_11g/jdeveloper/jdev/mywork/CoherenceApp/lib/coherence.jar!/tangosol-coherence.xml"
    2009-04-17 05:33:54.562/258.969 Oracle Coherence 3.4.2/411 <Info> (thread=[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Loaded operational overrides from resource "zip:D:/JDEV_11g/jdeveloper/jdev/mywork/CoherenceApp/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
    2009-04-17 05:33:54.562/258.969 Oracle Coherence 3.4.2/411 <D5> (thread=[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Optional configuration override "/tangosol-coherence-override.xml" is not specified
    2009-04-17 05:33:54.578/258.985 Oracle Coherence 3.4.2/411 <D5> (thread=[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified
    Oracle Coherence Version 3.4.2/411
    Grid Edition: Development mode
    Copyright (c) 2000-2009 Oracle. All rights reserved.
    *2009-04-17 05:33:55.750/260.157 Oracle Coherence GE 3.4.2/411 <Info> (thread=[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Loaded cache configuration from resource "zip:D:/JDEV_11g/jdeveloper/jdev/mywork/CoherenceApp/lib/coherence.jar!/coherence-cache-config.xml"*
    2009-04-17 05:34:17.390/281.797 Oracle Coherence GE 3.4.2/411 <D5> (thread=Cluster, member=n/a): Service Cluster joined the cluster with senior service member n/a
    2009-04-17 05:34:21.890/286.297 Oracle Coherence GE 3.4.2/411 <Info> (thread=Cluster, member=n/a): Created a new cluster "cluster:0x2FFB" with Member(Id=1, Timestamp=2009-04-17 05:34:09.203, Address=141.144.90.113:8088, MachineId=18289, Location=site:sg.oracle.com,machine:rajerama-sg,process:3816, Role=WeblogicServer, Edition=Grid Edition, Mode=Development, CpuCount=2, SocketCount=1) UID=0x8D905A7100000120B0D9DD3347711F98
    2009-04-17 05:34:27.000/291.407 Oracle Coherence GE 3.4.2/411 <D5> (thread=DistributedCache, member=1): Service DistributedCache joined the cluster with senior service member 1
    [EL Finer]: 2009.04.17 05:34:28.343--ServerSession(32927169)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Coherence(MetadataType)::Get: 2
    [EL Fine]: 2009.04.17 05:34:28.703--ServerSession(32927169)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Coherence(MetadataType)::Get: 2 result: null
    [EL Finer]: 2009.04.17 05:34:28.703--ServerSession(32927169)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Coherence(MetadataType)::Get: 2
    *[EL Fine]: 2009.04.17 05:34:28.703--ServerSession(32927169)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Coherence(MetadataType)::Get: 2 result: null*
    null
    Eventhough the method is called correctly, it does not return the value. Is there any other setup that has to be done?
    Regards
    Raji

    Hi Raji,
    You mentioned:
    >
    -Dtangosol.coherence.cacheconfig=D:/JDEV_11g/jdeveloper/jdev/mywork/CoherenceApp/CoherenceProject/src/META-INF/coherence-cache-config.xml
    >
    and
    >
    Persistence.xml and coherence-cache-config.xml are palced inside the jar file.
    >
    It appears that these are conflicting; as the system property indicates that the config should be read from a file, whereas the file is actually deployed in a jar.
    That being said, I would suggest double checking that the system property is actually being set in the JVM. In my testing, if I specify a cache config that does not exist, an exception will be thrown:
    java -Dtangosol.coherence.cacheconfig=foo.xml  com.tangosol.net.CacheFactory
    Oracle Coherence Version 3.4.2/411p3
    Grid Edition: Development mode
    Copyright (c) 2000-2009 Oracle. All rights reserved.
    Map (?): cache test
    2009-04-22 15:33:15.310/6.917 Oracle Coherence GE 3.4.2/411p3 <Error> (thread=main, member=1):
    (Wrapped: Failed to load the factory) java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
            at com.tangosol.util.ClassHelper.newInstance(ClassHelper.java:662)
            at com.tangosol.net.CacheFactory.getConfigurableCacheFactory(CacheFactory.java:602)
            at com.tangosol.coherence.component.application.console.Coherence.doCache(Coherence.CDB:9)
            at com.tangosol.coherence.component.application.console.Coherence.processCommand(Coherence.CDB:209)
            at com.tangosol.coherence.component.application.console.Coherence.run(Coherence.CDB:39)
            at com.tangosol.coherence.component.application.console.Coherence.main(Coherence.CDB:3)
            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.tangosol.net.CacheFactory.main(CacheFactory.java:1308)
    Caused by: (Wrapped: Failed to load configuration resource: foo.xml) java.io.IOException: Configuration is missing: "foo.xml", loader=null
            at com.tangosol.net.DefaultConfigurableCacheFactory.loadConfigAsResource(DefaultConfigurableCacheFactory.java:386)
            at com.tangosol.net.DefaultConfigurableCacheFactory.loadConfig(DefaultConfigurableCacheFactory.java:337)
            at com.tangosol.net.DefaultConfigurableCacheFactory.loadConfig(DefaultConfigurableCacheFactory.java:309)
            at com.tangosol.net.DefaultConfigurableCacheFactory.<init>(DefaultConfigurableCacheFactory.java:137)
            ... 15 moreThanks,
    Patrick

Maybe you are looking for

  • Error while sending email to Multiple Recipients

    Hi, I am trying to send email to multiple recipients .It works fine if all the email-addresses are valid. If even one is invalid throws exception .I wish to send it all the valid addresses even if some are invalid as this email will be going to 3000

  • Oracle not showing up in Tora database selection

    I'm running Oracle9i (9.2.0) and Tora-1.3.14.1-2. I can reach my selected DB via sqlnet with no problems. Yet, Oracle doesn't show up in my Connection menu. Is there something I'm doing wrong? Gene

  • How can i zoom the macbook pro retina camera?

    system preferences has no camera or video config and FaceTime preferences are dimmed for the new retina...  I want to create a video conf call in a conf room and need to zoom out. nothing I can find on the apple site discusses this...  thanks if you

  • Create a package for transport

    hi I work on a new project, and I wonder how I can create a package for transport  InfoObjects? best regard francoise

  • Photoshop blocked by exporting for Web

    Sometimes i work with big Photos (mostly 12440 x 6220 pixels) If i want to export this with the "Save for Web" Option, and the last before was an PNG file, photoshop does a preview of my big image in png. This needs a very long time (about a minute),