-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 
Author Message
 Post subject: Problems with Hibernate-plugins
PostPosted: Tue Jul 27, 2010 9:40 am 
Newbie

Joined: Mon Jul 26, 2010 9:45 am
Posts: 10
Hi,

i try to integrate Hibernate in my Eclipse 3.5.2 distribution, but after i installed Hibernate Tools and some JBoss-Tools
via the Eclipse Install mode, the following example does not work, as Eclipse does not find lots of Hibernate classes:

import project.core.src.main.java.org.hibernate.HibernateException;
import project.core.src.main.java.org.hibernate.Session;
import project.core.src.main.java.org.hibernate.SessionFactory;
import project.core.src.main.java.org.hibernate.cfg.Configuration;
import project.core.src.main.java.org.hibernate.connection.ConnectionProvider;;


/**
* @author Deepak Kumar
*
* http://www.roseindia.net
* Hibernate example to inset data into Contact table
*/
public class ELS {
public static void main(String[] args) {
Session session = null;

try{
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
//Create new instance of Contact and set values in it by reading them from form object

System.out.println("Inserting Record");
St st = new St();
st.setBeschreibung("blabla");
st.setBewertung(true);
st.setDauer(3);
st.setdMid(1);
st.setKlasse(1);
st.setSt_id(1);

session.save(st);
System.out.println("Done");
}catch(HibernateException e){
System.out.println(e.getMessage());
}finally{
// Actual contact insertion will happen at this step
session.flush();
session.close();

}

}
}

The auto import changes it to:

import javax.security.auth.login.Configuration;

But that does not make sence....

Pleas, i need some help.


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Tue Jul 27, 2010 6:28 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
all imports are wrong: the hibernate package is "org.hibernate" and not "project.core.src.main.org.hibernate"

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Fri Jul 30, 2010 6:14 am 
Newbie

Joined: Mon Jul 26, 2010 9:45 am
Posts: 10
Thanks....

although i fixed some bugs, i am getting this error, when connecting to the data base:

An internal error occurred during: "Fetching children of Database".

java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:133)
at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getTables(JDBCMetaDataDialect.java:26)
at org.hibernate.cfg.reveng.JDBCReader.processTables(JDBCReader.java:476)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:74)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:116)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:107)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:63)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:234)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


But in the console you can see

Hibernate: insert into ....

There is only a msg, that there are multiple bindings.

Has it something to do with wrong jar-files?

Thanks


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Fri Jul 30, 2010 9:31 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hard to tell as you didn't post much info on your classpath, my guess is that you have more than one slf4j implementation: you need exactly one api and one implementation.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Fri Jul 30, 2010 10:47 am 
Newbie

Joined: Mon Jul 26, 2010 9:45 am
Posts: 10
This is the configuration file..

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/xxx</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">hallo</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<mapping resource="St_Ereignis.hbm.xml"/>
</session-factory>
</hibernate-configuration>

I have integrated the jar hibernate3.jar from a hibernate-3.5.3-distribution and the postgresql-8.4-701.jdbc4.jar and my eclipse-version is 3.5.2


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Fri Jul 30, 2010 10:52 am 
Newbie

Joined: Mon Jul 26, 2010 9:45 am
Posts: 10
s.grinovero wrote:
Hard to tell as you didn't post much info on your classpath, my guess is that you have more than one slf4j implementation: you need exactly one api and one implementation.


When i only consider the jars slf4j-api-1.6.1.jar and slf4j-log4j12-1.6.1.jar i get the following error:

Failed to instantiate SLF4J LoggerFactory

So thats why i integrated all slfj4-jars from the slfj4-folder.

I also tried it with older slf4j-jars.


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Fri Jul 30, 2010 12:10 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
slf4j-log4j12-1.6.1.jar

this implementations requires log4j too (and a log4j configuration)

btw this version of hibernate uses slf4j 1.5.9

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Fri Jul 30, 2010 12:24 pm 
Newbie

Joined: Mon Jul 26, 2010 9:45 am
Posts: 10
s.grinovero wrote:
Quote:
slf4j-log4j12-1.6.1.jar

this implementations requires log4j too (and a log4j configuration)

btw this version of hibernate uses slf4j 1.5.9


Hi,

integrated the log4-jar and changed the slf4-version.

But i get the same error.

Thanks


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Fri Jul 30, 2010 12:49 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
i try to integrate Hibernate in my Eclipse 3.5.2 distribution, but after i installed Hibernate Tools and some JBoss-Tools...

which version of Hibernate? and why are you integrating it into Eclipse? Please consider that Hibernate Tools embed an old version of Hibernate to perform the tooling tasks - you shouldn't really integrate Hibernate in eclipse unless you know what you're doing and properly isolate the classes.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Mon Aug 02, 2010 5:05 am 
Newbie

Joined: Mon Jul 26, 2010 9:45 am
Posts: 10
Hi,

it is the version 3.5.3 of Hibernate. "Integration Hibernate into Eclipse" means, that i add the external Hibernate jars.

Thanks

Update:

Now i have access to the data base, but instead of inserting the values in the existing data base, the command creates a new table in postgresql with empty columns.


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Tue Aug 03, 2010 5:56 am 
Newbie

Joined: Mon Jul 26, 2010 9:45 am
Posts: 10
Any ideas, why Hibernate creates a new table, instead of inserting the values?

Thanks


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Tue Aug 03, 2010 10:24 am 
Newbie

Joined: Mon Jul 26, 2010 9:45 am
Posts: 10
Is it true, that there are problems with table and column-names in upper case?

After i changed my table in postgresql, i get the following errors:

28 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 23505
828 [main] ERROR org.hibernate.util.JDBCExceptionReporter - Batch-Eintrag 0 insert into st (kl, be, da, be, dm, pr, bm, se, a, af, az, t1, t2, t3, t4, sa, st) values ('1', 'Z', '3', '1', '1', 'Normal', '1', '1', '2', '4', '5', '1', '0', '0', '0', '0', '1') wurde abgebrochen. Rufen Sie 'getNextException' auf, um die Ursache zu erfahren.
828 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 23505
828 [main] ERROR org.hibernate.util.JDBCExceptionReporter - FEHLER: doppelter Schlüsselwert verletzt Unique-Constraint »st«
828 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at E.main(E.java:45)
Caused by: java.sql.BatchUpdateException: Batch-Eintrag 0 insert into st(k, be, da, be, dm, pr, bm, se, am, af, az, t1, t2, t3, t4, sa, st) values ('1', 'Z', '3', '1', '1', 'Normal', '1', '1', '2', '4', '5', '1', '0', '0', '0', '0', '1') wurde abgebrochen. Rufen Sie 'getNextException' auf, um die Ursache zu erfahren.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2569)
at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:459)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1796)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2708)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 6 more
Exception in thread "main" org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at E.main(E.java:45)
Caused by: java.sql.BatchUpdateException: Batch-Eintrag 0 insert into st (kl, be, da, be, dm, p, bm, se, am, af, azl, t1, t2, t3, t4, sa, st) values ('1', 'Z', '3', '1', '1', 'Normal', '1', '1', '2', '4', '5', '1', '0', '0', '0', '0', '1') wurde abgebrochen. Rufen Sie 'getNextException' auf, um die Ursache zu erfahren.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2569)
at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:459)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1796)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2708)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 6 more


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Wed Aug 04, 2010 10:33 am 
Newbie

Joined: Mon Jul 26, 2010 9:45 am
Posts: 10
Thanks.

i found my error. The last error msg was only because i wanted to insert the same row twice. According to the
preferences of primary keys, i got this error.

Best regards


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Wed Aug 18, 2010 6:01 am 
Newbie

Joined: Wed Aug 18, 2010 5:32 am
Posts: 1
Hi,

I also get the error

Quote:
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)


Could you explain how did you fix it?

Regards.


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate-plugins
PostPosted: Thu Aug 19, 2010 4:44 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
please open new threads for new different issues, and search in the forums before posting as these issues were widely discussed already.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.