facebook

net.sf.hibernate in Spring 1.2 ORM/DAO/Hibernate3 Libraries

  1. MyEclipse Archived
  2.  > 
  3. Application Servers and Deployment
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #252011 Reply

    dsurber
    Member

    The following line of code is maked as a compilation error.

    return getHibernateTemplate().load(Foo.class, new Long(id));
    

    The error is

    The type net.sf.hibernate.LockMode cannot be resolved. It is indirectly referenced from required .class files

    I’m using JDK 1.5, Spring 1.2, and Hibernate 3. My build path includes only the Spring 1.2 ORM/DAO/Hibernate3 libraries. It does not include the Spring 1.2 ORM/DAO/Hibernate2 libraries. Lots of Hibernate 3 code runs. I haven’t yet run any Spring tests because this DAO won’t compile.

    Seems like the Spring Hibernate3 lib directly or indirectly includes a reference to a Hibernate2 class.

    I found one forum post that seems to describe a related bug.

    http://www.myeclipseide.com/modules.php?op=modload&name=PNphpBB2&file=viewtopic&t=10475

    Douglas

    *** Date: Sat May 13 19:28:01 PDT 2006

    *** System properties:
    OS=Windows2000
    OS version=5.0
    Java version=1.5.0_06

    *** MyEclipse details:
    MyEclipse Enterprise Workbench

    Version: 4.1.1 GA
    Build id: 20060309-4.1.1-GA

    *** Eclipse details:
    Eclipse SDK

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse Platform

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse RCP

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse Java Development Tools

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse Plug-in Development Environment

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse Project SDK

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86
    -launcher
    C:\Program Files\eclipse\eclipse.exe
    -name
    Eclipse
    -showsplash
    600
    -exitdata
    964_48
    -vm
    C:\WINNT\system32\javaw.exe

    #252013 Reply

    dsurber
    Member

    I found the problem. When Eclipse resolved the import of the type HibernateTemplate, it resolved it as org.springframework.orm.hibernate.support.HibernateTemplate. This is incorrect. It should be resolved as org.springframework.orm.hibernate3.support.HibernateTemplate.

    Seems that even though I thought I was only loading support for Hibernate3, I also got some of the Hibernate2 stuff as well.

    #252016 Reply

    Haris Peco
    Member

    dsurber,

    check your project build path if you have included hibernate2 libraries – this features work fine except you include hibernate2 libraries

    Best

    #252017 Reply

    dsurber
    Member

    Looking at File>Properties>Java Build Path>Libraries the only libraries that mention Hibernate are

    Hibernate 3.0 Core Libraries
    Spring 1.2 ORM/DAO/Hibernate3 Libraries

    If I click Add Library… and select MyEclipse Libraries I see

    Spring 1.2 ORM/DAO/Hibernate2 libraries

    unchecked. I’m pretty sure I have only the Hibernate3 support included in my build pathy.

    #252019 Reply

    Haris Peco
    Member

    Douglas,

    spring hibernate jar contents both classes
    org.springframework.orm.hibernate.support.HibernateTemplate and
    org.springframework.orm.hibernate3.support.HibernateTemplate
    but MyEclipse will create DAO with hibernate3

    Have you created DAO in same project which have correct Hibernate3 libraries ?

    Please, can you send your DAO class (with imports) ?

    Thanks

    #252023 Reply

    dsurber
    Member

    My DAO class is working now. I understand the problem. The only issue is that Eclipse chose to import .hibernate3. instead of .hibernate2. Now that I know what is happening I can deal with it. Given that I selected Spring hibernate3 and specifically did not include hibernate2 I would expect that the hibernate2 support would not be visible, but it appears not. That seems like a bug to me, but not a major one.

    #252026 Reply

    Haris Peco
    Member

    Douglas,

    Spring jar contents both hibenrate DAO template and if you make DAO with MyEclipse then
    MyEclipse will import correct template (it will be hibernate3 when you choose hibernate3 libraries)
    If you make own DAO you have to choose correct template (Eclipse’s ‘organize import’ will offer both, but firts hibernate2)
    It is possible resolve only if we change spring libraries, but it can introduce compatiblility problems
    It’s imporant that you understand problem and you can care about this

    Thanks

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: net.sf.hibernate in Spring 1.2 ORM/DAO/Hibernate3 Libraries

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