HELP - Hibernate vs Toplink!!!

Hello Everybody,
I have some questions related with Hibernate vs Toplink.
1- To obtain that driver JDBC it gives back the amount of rows affected in each one of updates of a lot that is executed in batch. Hibernate to implement the optimistic lock, adds to each consultation a "WHERE >" where it compares the VERSION of the object in memory with the field VERSION of tuple corresponding in the DB. If it detected that rows were updated "0" it interprets that another user modified that object before and shoots an exception of Concurrence. When batch is used to execute a lot of consultations, driver gives back a vector like result. Each position of this vector this destining to indicate the amount of updates that they became in each consultation of the lot. The problem is that when using PreparedStatement (that is what Hibernate uses to execute the queries) the vector gives back to "-2" in all positions without concerning the real amount that were affected. The affected fact that driver it gives back to "-2" and not real amount
it for a consultation causes that Hibernate cannot determine if were or not a concurrence problem. We cannot modify Hibernate so that it knows to interpret the "-2" given back by driver because it would not be sufficient to determine if the version were or not modified. The safe SOLUTION to this problem would be that driver it gives back to Hibernate the affected real amount to him in each one of the positions. This is what Hibernate hopes. We can see the execution batch that implements Hibernate in org.hibernate.jdbc.AbstractBatcher>>executeBatch of the
distribution of Hibernate. Could be solve this problem with Toplink?
2-Security by dominion. How we would take label security with Hibernate? I know it is possible much better with Toplink but what about Hibernate.
3-Multiple mappings with Hibernate. Hibenate makes alternative mappings and for this reason it raises more of the necessary thing affecting the performance. Although with them we solved several problems of performance turn out uncomfortable to maintain to them. How we can improve it. Could be solve this problem with Toplink?
Best Regards,
Seba.

1- This issue is down in the driver, and we have seen it before. We have worked with the driver team to come up with a solution in the 10.1.3.1 release. The client would use the Oracle9Platform and call this method session.getLogin().getPlatform().setUsesNativeBatchWriting(true); This will cause TopLink to call special API on the Oracle Drivers to do what is expected of locking and batching together.
2- I assume that you are referring to OLS and VPD. TopLink supports this, but we will need more information to help you further.
3- Not sure what you mean here... In TopLink you can map multiple mappings to the same entity. is that what you are referring to?

Similar Messages

  • Convert from Hibernate to TopLink

    Hi,
    I would like to convert from Hibernate and Tomcat to TopLink and IAS with the
    latest version 10.1.3.1 that include the EJB3.0 and JPA.
    What is the effort that will be needed to for this convertion (mainly the Hibernate to Toplink convertion)?
    Do you know about a migration tool for that purpose?
    Thanks
    Yafit

    Hi Yafit,
    For the sake of those who might be interested I'm posting the response I had given to you in email.
    If you are using Hibernate with JPA the migration should not be a large effort. The persistence.xml (deployment configuration) file will need to be updated of course. A question for you is whether you're using many proprietary Hibernate features or have you used only JPA defined mappings. Anything proprietary will require attention. Also, Hibernate's JPQL supports some non-standard features so this question about staying within the spec applies to queries too.
    There are no migration tools for moving from Hibernate JPA to TopLink JPA as the differences are mostly in configuration which is easy enough to adjust manually.
    --Shaun                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • EJB, Hibernate or TopLink?

    Hi all,
    In our company we are using an Oracle database, and we have a lot of java applications running on our application servers. In the future for our new applications we want to change the way we persist our data to the database and we are doubting between EJB 3.0 when the specs are final, Hibernate and Oracle TopLink.
    Which could be the best choice regarding installed base, stability, performance, maintainability and scalability.
    Hope to hear from you.
    Regards,
    Ronald

    See answer in Re: EJB, Hibernate or TopLink?

  • Please help.  Got TopLink working, but now I can't run a JSP page

    I am using JDeveloper 9.0.3.
    I got TopLink working successfully. Meaning I can access the DB using my mapped TopLink classes from my java code in JDeveloper.
    However, now I can't even run the default .jsp page.
    I am getting the error:
    Error instantiating application at file:/C:/LBIT/LBIT-oc4j-app.xml: Error parsing data-sources config at file:/C:/LBIT/LBIT-data-sources.xml: Fatal error at line 0 offset 0 in file:/C:/LBIT/LBIT-data-sources.xml: The encoding "windows-1252" is not supported.
    If I go change the "LBIT-data-sources.xml" file to "ISO-8859-1," as soon as I run the .jsp page (from JDeveloper) the "LBIT-data-sources.xml" file gets overwritten with a new one that contains the "windows-1252" encoding line again.
    What can I do to fix this???
    I know someone else has run into this problem!!!
    Please help. Thanks so much.
    Andy

    You could change the encoding by doing the following.
    Stop Embedded OC4J Server (Run | Terminate | Embedded OC4J Server)
    Tools | Preferences
    Select Environment
    Change the Encoding to ISO-xxxxx
    Click OK
    Run your JSP now.
    Atleast this should fix encoding generated into data-sources.xml
    raghu
    JDev Team

  • Help in building Toplink query with Date

    Hi,
    Can any anybody help me on how to build the toplink expression for the date.
    We are passing the date object and I'm getting the date as (Eg:"Sat May 31 16:34:35 EDT 2008").
    When I passing in like this I'm not able to det the data although I got data in the database.
    Expression dateExp = builder.get(testDate").equal("zzzzz.getDate()");
    Any help is appreciated.
    Thanks,
    Basil

    Hello Basil,
    Can you turn on logging and post the sql that gets generated? Also, what is the database/driver version being used, and what is the database column type for the date? This could be a problem with the precision of the date object being passed in not matching the date objects used in the database. If you read an object by its primary key, is the date infomation populated correctly?
    Best Regards,
    Chris

  • Help with: oracle.toplink.essentials.exceptions.ValidationException

    hi guys,
    I really need ur help with this.
    I have a remote session bean that retrieves a list of books from the database using entity class and I call the session bean from a web service. The problem is that when i display the books in a jsp directly from the session bean everything works ok but the problem comes when I call the session bean via the web service than it throws this:
    Exception Description: An attempt was made to traverse a relationship using indirection that had a null Session. This often occurs when an entity with an uninstantiated LAZY relationship is serialized and that lazy relationship is traversed after serialization. To avoid this issue, instantiate the LAZY relationship prior to serialization.
    at oracle.toplink.essentials.exceptions.ValidationException.instantiatingValueholderWithNullSession(ValidationException.java:887)
    at oracle.toplink.essentials.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:233)
    at oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:105)
    at oracle.toplink.essentials.indirection.IndirectList.buildDelegate(IndirectList.java:208)
    at oracle.toplink.essentials.indirection.IndirectList.getDelegate(IndirectList.java:330)
    at oracle.toplink.essentials.indirection.IndirectList$1.<init>(IndirectList.java:425)
    at oracle.toplink.essentials.indirection.IndirectList.iterator(IndirectList.java:424)
    at com.sun.xml.bind.v2.runtime.reflect.Lister$CollectionLister.iterator(Lister.java:278)
    at com.sun.xml.bind.v2.runtime.reflect.Lister$CollectionLister.iterator(Lister.java:265)
    at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:129)
    at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:152)
    at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:322)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:681)
    at com.sun.xml.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:65)
    at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:168)
    at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:152)
    at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:322)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:681)
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:277)
    at com.sun.xml.bind.v2.runtime.BridgeImpl.marshal(BridgeImpl.java:100)
    at com.sun.xml.bind.api.Bridge.marshal(Bridge.java:141)
    at com.sun.xml.ws.message.jaxb.JAXBMessage.writePayloadTo(JAXBMessage.java:315)
    at com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:142)
    at com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:108)
    at com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:258)
    at com.sun.xml.ws.transport.http.HttpAdapter.encodePacket(HttpAdapter.java:320)
    at com.sun.xml.ws.transport.http.HttpAdapter.access$100(HttpAdapter.java:93)
    at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:454)
    at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
    at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
    at com.sun.enterprise.webservice.JAXWSServlet.doPost(JAXWSServlet.java:176)
    ... 29 more
    This happens when I test the web service using netbeans 6.5.
    here's my code:
    session bean:
    ArrayList bookList = null;
    public ArrayList retrieveBooks()
    try
    List list = em.createNamedQuery("Book.findAll").getResultList();
    bookList = new ArrayList(list);
    catch (Exception e)
    e.getCause();
    return bookList;
    web service:
    @WebMethod(operationName = "retrieveBooks")
    public Book[] retrieveBooks()
    ArrayList list = ejbUB.retrieveBooks();
    int size = list.size();
    Book[] bookList = new Book[size];
    Iterator it = list.iterator();
    int i = 0;
    while (it.hasNext())
    Book book = (Book) it.next();
    bookList[i] = book;
    i++;
    return bookList;
    Please help guys, it's very urgent

    Yes i have a relationship but i didnt want it to be directly. Maybe this is a design problem but in my case I dont expect any criminals to be involved in lawsuit. My tables are like that:
    CREATE TABLE IF NOT EXISTS Criminal(
         criminal_id INTEGER NOT NULL AUTO_INCREMENT,
         gender varchar(1),
         name varchar(25) NOT NULL,
         last_address varchar(100),
         birth_date date,
         hair_color varchar(10),
         eye_color varchar(10),
         weight INTEGER,
         height INTEGER,
         PRIMARY KEY (criminal_id)
    ENGINE=INNODB;
    CREATE TABLE IF NOT EXISTS Lawsuit(
         lawsuit_id INTEGER NOT NULL AUTO_INCREMENT,
         courtName varchar(25),
         PRIMARY KEY (lawsuit_id),
         FOREIGN KEY (courtName) REFERENCES Court_of_Law(courtName) ON DELETE NO ACTION
    ENGINE=INNODB;
    CREATE TABLE IF NOT EXISTS Rstands_trial(
         criminal_id INTEGER,
         lawsuit_id INTEGER,
         PRIMARY KEY (criminal_id, lawsuit_id),
         FOREIGN KEY (criminal_id) REFERENCES Criminal(criminal_id) ON DELETE NO ACTION,
         FOREIGN KEY (lawsuit_id) REFERENCES Lawsuit(lawsuit_id) ON DELETE CASCADE
    ENGINE=INNODB;So I couldnt get it.

  • Converting from Hibernate to TopLink

    Hello, everyone:
    We're exploring the possibility of converting our current
    Hibernate-based framework to TopLink. I'd like to know
    if anyone has already done this type of migration, along
    with any useful information about the experience...
    Regards,
    Oswald

    Refer to
    Re: Toplink vs. Hibernate
    and the tutorial on Toplink.
    http://www.oracle.com/technology/products/jdev/101/howtos/jsftoplink/index.html

  • HELP - 'Hibernate' option disappeared completely from the system

    My new Satellite L355-S7831(Vista SP1) 'Hibernate' option disappeared completely from the system (after I did 'Disk Cleanup' function??).
    I could not find anywhere to enable the Hibernate function under Power Options (It's available in XP). I re-installed the display card driver, but it didn't solve the problem... HELP!!!
    Solved!
    Go to Solution.

    See this Microsoft document...
       How to disable and re-enable hibernation on a computer that is running Windows Vista
    -Jerry

  • Bench mark hibernate vs Toplink

    Is anyone aware of such a benchmark? thanks

    The only standard benchmark that I am aware of is SpecJ. It is a full J2EE benchmark with persistence being one component contributing to the overall application's throughput.
    TopLink is part of Oracle's World Record SpecjAppServer2004 results (1, 2, 3, 4). To the best of my knowledge none of the other ORM products are used by their respective containers for their results. With data access being a major component of this benchmark it has enabled us to continually optimize concurrent throughput and data access optimization features that are available in our recent releases and now in EclipseLink.
    As a TopLink consultant I was involved in several benchmarking activities over the years as well as our ongoing internal verifications. I have seen TopLink win these benchmarks across many usage usage scenarios. The most difficult part of benchmarking is building a representative system and spending the time to tune the application based on its characteristics and the features of the ORM solution in use.
    I believe we have the best performing and scaling Java persistence solution available. Our out of the box features can be easily tuned to get the results you need.
    Doug Clarke
    TopLink Product Management
    EclipseLink Project co-lead

  • Help with useing toplink please..

    Hello
    I am writing J2EE apps that will run on a 10g app server. I thought that toplink was what I should be using to do my model layer. But there are several simple things I can't find out how to do. Things like make a LOV, how do I set a where clause and restrict what the end user is looking at?
    Should I be using the ADF stuff instead? I was under the impression TopLink was the future direction at oracle so thats why I picked it. I have worked all the toplink tutorials I found. I can create mappings and all that. Setting it up isn't the problem, using it once I have it set up thats what I need to figure out. Can anyone point me in the direction of some tutorials or examples on how to use toplink? (especially in j2ee apps).
    Thanks
    troy

    Troy,
    TopLink is a core piece of Oracle's enterprise Java strategy. We are dedicated to standardization of ORM persistence through EJB 3.0 and TopLink is our implementation and the basis of Sun's reference implementation. Additionally, the use of TopLink is not mutually exclusive to using ADF. Within ADF you can use a variety of persistence technologies including TopLink.
    Here is a sample workshop on building applications with TopLink in ADF: http://www.oracle.com/technology/obe/obe9051jdev/ide1012/adfworkshop/buildingadfapplicationsworkshop.htm
    In order to filter or restrict results coming back from the database you need to make use of queries. TopLink has 5 query options available:
    1. TopLink's Expression API
    2. EJB QL
    3. Custom SQL
    4. Stored Procedures
    5. Query By Example
    Quick Tour overview: http://www.oracle.com/technology/products/ias/toplink/quicktour904/que01_01.htm
    You can develop your queries directly in the API of your application or you can use the mapping editors (JDeveloper or Workbench) to declaratively construct your queries. I would recommend using the mapping editors and the expression framework. This will allow the tools to assist you as your application evolves. When mappings change you will be notified if they break any of your defined queries.
    In the 10.1.3 documentation you can start learning about queries at:
    http://download-west.oracle.com/otn_hosted_doc/toplink/1013/DP4/_html/persun005.htm#sthref5432
    Cheers,
    Doug

  • TopLink vs Hibernate... revisited... again :)

    Would it be possible to get a Toplink versus Hibernate (or other ORM frameworks) going here?
    It seems like the explosive adoption of Hibernate and the associated popularity contest in the industry has put some of us in a position where we're constantly trying to sell the-right-tool-for-the-right-job which, at least for me, seems to disqualify hibernate a lot of times, esp when scalable persistence is a requirement. It seems to be really difficult to convince folks that the popularity of hibernate doesnt mean it's by default the right option.
    I've seen at least two threads on theserverside.com about hibernate versus cayenne, and despite the amount of noise in the threads, there were a few folks making some decent points. The TopLink folks were very quiet on the threads, but I know they were reading :)
    So, anyone out there have any experience comparing TopLink and Hibernate? What do you all see as the shortcomings of each, esp from a technical architecture standpoint? Are GUI tools as overrated as Gavin claims? Where's annotation support for TopLink? Is TopLink overpriced? Is Hibernate's multi-tier non-integrated caching biting anyone on big projects where persistence needs to scale, or is integrated caching overrated? Is Hibernate3 really going to fix shortcomings that TopLink already addresses in current releases? What do you all think the Hibernate crew is doing right that the TopLink crew is doing wrong and vice versa? I'm not assuming any of these questions even merit answer but just interested in some objective discussion in a forum where TopLink guys might have a stronger voice.
    Take care!

    Well, I've only got a few minutes, but I could go on for hours.
    I'll start by saying that I've been doing ORM for longer than many people knew that you could. I had been a previous TOPLink user but went for about two years without having to do any ORM.
    Then, last year I started a new project for a client who insisted we use SqlServer and was hesitant to pay for any software unless it was absolutely necessary. (This is common these days, as the fact that there is so much free software out there encourages folks to try out the free stuff before paying for something that may or may not be better). Comparing the feature list of Hibernate to TOPLink and doing a little checking seemed to indicate that going with Hibernate would be a perfectly reasonable thing to do.
    I will state, uncategorically, that this was the worst technical decision I have ever made in my life... twenty-plus years of Software Application Developing, most of it with object-oriented languages (Smalltalk and Java).
    NOTE: I must couch that statement with the caveat that part of this was due to my naivete about the architectural assumptions I made about Hibernate before including it in my application. If I would have merely learned about Hibernate's architectural assumptions (though this was not easy due to their poor documentation) and allowed these assumptions to drive my development, it would not have been nearly as painful, just yucky. Also, if my objects were much simpler/flatter and I didn't need caching to speed things up, Hibernate could have worked just fine out of the box. Problem is, I had a complex system, needed caching, and Hibernate gave me nightmares as I tried to navigate through it.
    As a test-first developer, I don't care about the GUI tools, as I'm happy to write tests to verify I can store and retrieve objects, then write the mappings and find out if it passes. What I would like is the ability to allow two threads to read the same object and not have to bring two copies of the object into memory or read the database twice. Call me crazy, but it just seems like object identity is a useful thing... perhaps my twenty years of developing object-oriented software has skewed my reasoning and I need to think like folks who haven't been programming as long.
    Hibernate's poor documentation did make it clear that it did not want me to think this way, but it also suggested that, if I wanted to think this way, it could cache objects for me so it wouldn't hit the database twice. And, I'm sure it could have cached objects in some form, but not the form I wanted. Though I thought I followed the instructions on how to set up my cache, I found that reading the same object twice didn't always get the same (as in "==") object back.
    To try to figure out why not (or why other things that an experienced object-oriented software developer couldn't figure out by reading the documentation), I had to dive into the code. This felt like diving into a water source in hopes of finding some gems, but discovering that I was swimming in a sewer full of, well, stuff that you'd find in a sewer.
    Although Hibernate advertises itself as a framework, it is much more of a blackbox framework than a whitebox. Most of the methods and many of the classes are private or protected final. There are very few places to extend what's there. And there are virtually none that allow you to override their architectural assumptions.
    The biggest architectural assumption I found to be problematic was that application developers can't be trusted to know which objects they intended to read and which they intended to write. Therefore, Hibernate "protects" you from having two sessions refer to (that's right, refer to, not modify) a collection of objects.
    In the end, we ended up having to open up the source code and make some modifications in order to make our application run with reasonable performance. We had a lot of fairly deep objects (objects that contained objects that contained objects...) and the idea of not caching the ones that were not being modified across sessions just didn't cut it for us.
    Additionally, we've spent the last few months supporting the app that we finally got into production, and greater than 75% of our bug fixing time has been due to the fact that Hibernate actually reads in objects from several places and it is difficult to tap into THE place an object is read in... because there isn't one. It goes through all sorts of intermediate states and we found out that having one process that is reading objects while another is trying to write the same object can cause some unfortunate side effects, even if you put synchronization locks in the obvious places.
    We ended up with many person months of effort and a lot of special classes getting Hibernate to do what we wanted it to do, and had to open the source code (which will make it hard to ever upgrade to the next version).
    Just recently we started a new project (where Oracle was the corporate standard DB) and decided we'd try to use TOPLink. Having not used it for several years, I had hoped it was going to be much cleaner than Hibernate to hook into our persistence layer. It was a piece of cake. In a few days we were doing what took us months to do with Hibernate, and we didn't have to perform any unnatural acts to get there.
    I would recommend Hibernate to anyone who didn't know how to build a reasonably factored object-oriented system and didn't mind forcing their system architecture to fit Hibernate's architectural assumptions. But, if you think you might have reason to define your own architecture or modify Hibernate's default behavior, TOPLink is well worth the licensing fees. Not to mention the cost of your sanity.
    Is Hibernate really free? Only if you don't value your time. I also found that you can buy outrageously priced support from JBoss to make up for their poor documentation on their poorly architected ORM blackbox framework. The documentation for TOPLink is far superior, and the simplicity of doing simple customizations and tweaks is like night and day.

  • JPA: Toplink vs Hibernate

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

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

  • What are the relation between JPA and Hibernate, JPA and TopLink?

    What are the relation between JPA and Hibernate, JPA and TopLink?
    Can JPA instead of Hibernate and TopLink?

    The Java Persistence API (JPA) is the object relational mapping persistence
    standard for Java. Hibernate and TopLink provide an Open source Object-relational mapping framework for Java.
    They provide an implementation for the Java Persistence API. In my opinion, both Hibernate and TopLink provide support to JPA
    and they can also be regarded as the complementary to JPA.
    Let's wait to see other person's opinions.

  • Hibernate's dual-layer cach and TopLink's caching strategy

    Dear members,
    I understand that caching between hibernate and toplink is implemented (or utilized) differently. Hibernate seems to have 'dual-layer caching' (which may imply they have two layers of cache) whereas TopLink has session cache and shared cache. The way I see it, they seem to be aiming for the same thing. Are there any differences between (obviously there are, only that I do not know them) those two caching architectures, and how different are they?
    Howard

    Yes there are differences :) For details check out
    TopLink vs Hibernate... revisited... again :)
    and
    Indirection - how are references resolved after session has been closed?

  • Is it Possible to Combine Hibernate + Swing?????

    Hi Xperts,
    Is it possible to combine Hibernate + Swing?
    (My Point of View Hibernate Contains Transaction, Session... But In Swing Session??????)
    So i have lot of confusions.
    SO
    if Hibernate + Swing
    IF YES. HOW? ELSE TELL THE REASON.
    I EAGERLY WAITING FOR YOUR REPLY
    Thanks
    Edward and Hari

    Hi Duffymo - thanks for responding. It's fun to discuss this with somebody; I don't usually get many reasonable/friendly responses on the Hibernate user forum.
    What I mean by transaction based identity is thatin
    the normal, recommended Hibernate process (one
    session per transaction), objects fetched in
    different transactions do not == each other. Solet's
    say I do the following:
    * Start session 1 and transaction 1, fetch object
    with primary key 5, and store it in variable obj1.
    Commit transaction 1 and close session 1.
    * Start session 2 and transaction 2, fetch object
    with primary key 5, and store it in variable obj2.
    Commit transaction 2 and close session 2.
    * At this point, even though they represent thesame
    row in the database, obj1 != obj2. I'll assume you mean !obj1.equals(obj2)here, because [obj1 != obj2[/code] even without
    Hibernate if the two references point to different
    locations in memory in the same JVM. The equals
    method can be overridden. You can decide to check
    equality only examining the primary keys, or you can
    do a field by field comparison. If the class checks
    equality on a field by field basis, the only way
    they'll not be equal is if you change values.I really do mean == in this case. If those two fetches happened within the same session, Hibernate would return the identical object from it's cache. Here's some pseudo-code illustrating what I mean:
    Session firstSession = sessionFactory.openSession(); //Start an empty session
    Transaction tx1 = firstSession.beginTransaction();
    Object obj1 = firstSession.get( Person.class, new Long(5) ); //Fetches row 5 from the database
    tx1.commit();
    Transaction tx2 = firstSession.beginTransaction(); //Start a new database transaction, but still use the same session cache.
    Object obj2 = firstSession.get( Person.class, new Long(5) ); //Just returns the same object it previously fetched
    tx2.commit();
    obj1 == obj2; //Returns true, because we're pointing to the exact same objects
    obj1.equals( obj2 ); //Obviously returns true since they're pointing to the same object
    Session secondSession = sessionFactory.openSession(); //Start an empty session
    Transaction tx3 = secondSession.beginTransaction(); //New transaction in the empty session, no cached objects
    Object obj3 = secondSession.get( Person.class, new Long(5) ); //Returns a newly created object, not in our session cache
    tx3.commit();
    obj1 == obj3; //Returns FALSE, these are two separate objects because they were fetched by different sessions.
    obj1.equals( obj3 ); // Depends on whether the database row was modified since we fetched obj1
    It sounds like you want an Observer pattern, where
    every client would deal with a single model and
    changes are broadcast to every registered Observer.
    That's just classic MVC, right? In that case, every
    y client might have an individual view, but they're
    all dealing with the same model. Changes by one is
    reflected in all the other views in real time.That would be awesome, but doesn't seem feasible. Our Swing clients are spread all around the world, and creating a distributed event notification system that keeps them all in sync with each other sounds very fun but extremely out of scope for this project. We're trying to make Hibernate manage the object freshness so that our Swing application clients may slowly become out of date, but when we trigger certain actions on the client (like a user query, or the user clicking a 'refresh' button) they refresh portions of their data model from the central shared database.
    >
    The reason that this is pertinent is because Swing
    expects objects to be long-lived, so that they canbe
    bound to the UI, have listeners registered withthem,
    they can be used in models for JTables, JLists,etc.
    In a typical complex Swing application, your only
    choice is to use a very long-lived session,because
    it would break everything if you were getting
    different copies of your data objects every timeyou
    wanted to have a transaction with the database. As
    shown above, a very long-lived session will leadto
    very out-of-date information with no good way to
    refresh it.Maybe the problem is that you don't want copies of
    the data. One model. Yes?One data model with real-time updates between all the connected clients would be ideal. However, I don't think that Hibernate is designed to work this way - it's really not even a Hibernate issue, that would be some separate change tracking infrastructure.
    Realistically, what I was hoping for is that we could have a single long-running Hibernate session so that we're working with the same set of Java objects for the duration of the Swing application lifetime. The problem that I'm running into is that Hibernate does not seem structured in a way that lets me selectively update the state of my in-memory objects from the database to reflect changes that other users have made.
    Certainly you've used JDBC. 8) That's what
    Hibernate is based on. TopLink is just another O/R
    mapping tool, so it's unlikely to do better. JDO
    doesn't restrict itself to relational databases, but
    the problem is the same.You're right, I have used JDBC, in fact we wrote a JDBC driver for FileMaker Pro so I'm pretty familiar with it. What I meant is that I've never tried using raw JDBC within a Swing application to manage my object persistence.
    I have not used TopLink and I haven't heard much about it, but I did see some tidbits on an Oracle discussion board comparing Hibernate with TopLink that made it sound like TopLink had better support for refreshing in-memory objects. Not having used TopLink myself, I can't say much else about what it's strengths/weaknesses are compared to Hibernate. It's not really an option for us anyway, because you have to pay a per-seat licensing charge, which would not work for this project.
    I know almost nothing about JDO except that it sounds really cool, is pseudo-deprecated, and it's probably too late for us at this point to switch our project to use it even if we wanted to.
    I don't think the problem is necessarily the
    persistence; it's getting state changes broadcast to
    the view in real time. It's as if you're writing a
    stock trading app where changes have to be made
    available to all users as they happen. Fair?Yes, I agree that the core issue is getting state changes broadcast to the view, but isn't that within the responsibility of the persistence management? How are we supposed to accomplish this with Hibernate?
    An excellent, interesting problem. Thanks for
    answering. Sincerely, %Likewise. I would stress again that I'm not anti-Hibernate in general (well maybe a little, but that's mostly because of bad attitudes on the support forums), I just have not found a way to make it work well for a desktop GUI client application like Swing. Thanks for your help, and I would love to continue the conversation.

Maybe you are looking for

  • Some doubts in upgradation

    hi i studied some upgradation documents i have some doubts. please dont give any help files or again links for upgradation bec i need some scenerio why they need to follow this steps Check compounding consistency in MultiProviders Info Cubes Fact vie

  • Missing objects in SDK

    <p> <span style="font-size: 8pt; font-family: Verdana">HI Friend, </span> </p> <p> <span style="font-size: 8pt; font-family: Verdana">We are trying to develop the BO reports through SDK, the following objects are not available in SDK.</span><span sty

  • HP officejet 6600 connected to wifi but no ping

    Hi we have an officejet 6600 printer installed with the latest firmware. Since last weekend we cannot ping the printer any more. Not from mac (without firewall software) nor from pc. The printer is connected to the wireless network. Het gets an IP ad

  • Catalog in SUS

    Hi experts Please someone could explain-me a context for use catalog in SUS, I could see in a documentation that is it a scenario possible, what is business scenario? Thanks Nilson

  • I have been unable to connect to the iTunes store via my computer for the last 2 days.  What is going on?

    I have been unable to connect to the iTunes store via my computer for the last few days.  It is rather frustrating.  Is something wrong?