Hello,
I have problems when trying to learn Hibernate and I am a newbie to this and not senior of Java either. Hope anyone can help out. Thanks in advance!
The short version of the problem is "duplicate class: org.hibernate.tutorial.domain.Event" when I am trying to build the tutorial (
http://www.hibernate.org/hib_docs/v3/re ... stapp.html) with Ant. It gets stuck on the "Compile" tag. See below for more details. I believe I have followed the instructions correctly, except the part where I should enable some kind of logging. I guess that doesn't matter, right?
Version of Hibernate: 3.3.1.GA:
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="events.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class>
</hibernate-mapping>[/b]
[b]Code between sessionFactory.openSession() and session.close():
Code:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);
session.save(theEvent);
session.getTransaction().commit();
Full stack trace of any exception that occurs:
C:\TestArea\Hibernate>ant
Code:
Buildfile: build.xml
clean:
[delete] Deleting directory C:\TestArea\Hibernate\bin
[mkdir] Created dir: C:\TestArea\Hibernate\bin
copy-resources:
[copy] Copying 2 files to C:\TestArea\Hibernate\bin
[copy] Copied 2 empty directories to 1 empty directory under C:\TestArea\Hi
bernate\bin
compile:
[javac] Compiling 3 source files to C:\TestArea\Hibernate\bin
[javac] C:\TestArea\Hibernate\src\events\Event.java:5: duplicate class: org.
hibernate.tutorial.domain.Event
[javac] public class Event {
[javac] ^
[javac] C:\TestArea\Hibernate\src\events\EventManager.java:26: cannot access
events.Event
[javac] bad class file: C:\TestArea\Hibernate\src\events\Event.java
[javac] file does not contain class events.Event
[javac] Please remove or make sure it appears in the correct subdirectory of
the classpath.
[javac] Event theEvent = new Event();
[javac] ^
[javac] 2 errors
BUILD FAILED
C:\TestArea\Hibernate\build.xml:21: Compile failed; see the compiler error outpu
t for details.
Total time: 2 seconds[/b]
[b]Name and version of the database you are using:
hsqldb 1.8.0.10
Best Regards
Niklas