facebook

Hibernate Spring tutorial – data not persisting in Oracle

  1. MyEclipse Archived
  2.  > 
  3. Documentation
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #291717 Reply

    gowgow
    Member

    I’m writing in regards to this tutorial:
    http://www.myeclipseide.com/documentation/quickstarts/hibernateandspring/

    When I run the application created in this tutorial, I’m having a strange issue.
    It appears as if everything is fine. The application saves a user, loads and reads from a user and it works just fine. I removed the code that deletes the user. If I change the code to try to insert a duplicate user with the same id, I get the “Unique Contraint” error that I would expect.

    The problem is, the data isn’t actually getting saved into Oracle (I used Oracle Express instead of mySql). It’s like the programming is running the SQL inserts in Oracle, but then not committing the change.

    Does anyone have any ideas what I should check?

    Another thing. The “BusinessLogic.java” class shown in the tutorial is missing it’s import statements and won’t compile until you add them.
    I’m having a hell of a time getting any of these myEclipse tutorials to work. Don’t get me wrong, they’re excellent. But it should would be nice if you didn’t need to screw with them in order to get them to work. One more minor point is that the tutorial needs to be updated to show the current versions of myEclipse, Spring and Hibernate.

    Thanks in advance for your help

    #291719 Reply

    gowgow
    Member

    My bad. Instead of searching Google, I should have searched this forum for an answer. The fix is to add <property name=”connection.autocommit”>true</property> to hibernate.cfg.xml

    It looks like this tutorial has had this problem for a very long time. Please fix so that others do not experience the headache of troubleshooting issues like this.

    #291728 Reply

    gowgow
    Member

    I’m having another problem. I’m trying to write a simple guestbook using Spring HIbernate and a servlet.
    I wrote a GuestBookList class with the following code:

    System.out.println(“in getGuestBooks1”);
    BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(“applicationContext.xml”));
    System.out.println(“in getGuestBooks2”);
    PersistenceLayer persistenceLayer = (PersistenceLayer) beanFactory.getBean(“persistenceLayer”);
    System.out.println(“in getGuestBooks3”);
    ArrayList myGuestBooks=(ArrayList)persistenceLayer.findAllGuestBooks();
    System.out.println(“in getGuestBooks4444”);

    This code works fine from a java application, but when I call it from a servlet, I’m getting this error:

    SEVERE: Servlet.service() for servlet ImageTest threw exception
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘persistenceLayer’ defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean ‘GuestbookDAO’ while setting bean property ‘guestBookDAO’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘GuestbookDAO’ defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean ‘sessionFactory’ while setting bean property ‘sessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V

    I’m sure as a newbie I’m overlooking something that is simple to fix. Do I need to do something in order to enable the use of the sessionFactory from with a servlet? Thanks

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Hibernate Spring tutorial – data not persisting in Oracle

You must be logged in to post in the forum log in