-->
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.  [ 4 posts ] 
Author Message
 Post subject: rows disappear
PostPosted: Tue Mar 28, 2006 9:13 am 
Newbie

Joined: Tue Mar 28, 2006 8:56 am
Posts: 3
Hi,

I have configured postgres 8.1 and i followed this tutorial on hibernate using the newest hibernate api:
http://www.hibernate.org/hib_docs/v3/re ... ersistence

When I persist the Event object it really goes into the db.

But when i try to receive objects hibernate returns an empty list and when i check the db all the rows have disappeared.

Logging with log4j didn't reveal any information.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 11:08 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
and we're supposed to help find out what's going wrong by using those four sentences alone?

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject: rows disappear
PostPosted: Tue Mar 28, 2006 11:51 am 
Newbie

Joined: Tue Mar 28, 2006 8:56 am
Posts: 3
so, to express myself more precise,

i tried the basics tutorial at
http://www.hibernate.org/hib_docs/v3/reference/en/html/

So, I managed to store an Event object in HSQLDB database.

But when I try to retrieve the objects from the db, as a result i get an empty list and the rows disappear from the database table!

The code to retrieve the data:

public static void main... :

List events = listEvents();
for (int i = 0; i < events.size(); i++) {
Event theEvent = (Event) events.get(i);
System.out.println("Event: " + theEvent.getTitle() +
" Time: " + theEvent.getDate());
}
HibernateUtil.getSessionFactory().close();

private List listEvents() {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List result = session.createQuery("from Event").list();
session.getTransaction().commit();
return result;
}

I tried this using HSQLDB and PostgreSQL and both did the same thing.

I use following configuration:
<?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>
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:hsql://localhost</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>

<mapping resource="events/Event.hbm.xml"/>

</session-factory>
</hibernate-configuration>


And I use following mapping file:
<?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>


Top
 Profile  
 
 Post subject: rows disappear
PostPosted: Tue Mar 28, 2006 12:14 pm 
Newbie

Joined: Tue Mar 28, 2006 8:56 am
Posts: 3
Oh I solved the problem myself. It is in the configuration file. But if someone guesses which line causes the rows in db disappear when making a query, i'll give a credit :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.