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.  [ 12 posts ] 
Author Message
 Post subject: Problems with the Tutorial
PostPosted: Sun Jan 29, 2006 3:53 am 
Newbie

Joined: Sun Jan 29, 2006 3:37 am
Posts: 10
Hibernate version:
version 3.1

Full stack trace of any exception that occurs:
Code:
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.postgresql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.format_sql=true, hibernate.query.substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=pg, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:postgresql:template1, hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Environment <clinit>
INFO: using java.io streams to persist binary types
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Initial SessionFactory creation failed. org.hibernate.HibernateException: /hibernate.cfg.xml not found
Exception in thread "main" java.lang.ExceptionInInitializerError
   at src.util.HibernateUtil.<clinit>(HibernateUtil.java:20)
   at src.events.EventManager.createAndStoreEvent(EventManager.java:22)
   at src.events.EventManager.main(EventManager.java:14)
Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
   at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
   at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1265)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1287)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1274)
   at src.util.HibernateUtil.<clinit>(HibernateUtil.java:14)
   ... 2 more


Name and version of the database you are using:
PostgreSQL 8.0



I am trying to get hibernate running from the tutorial example found here:
http://www.hibernate.org/hib_docs/v3/re ... orial.html

I am having a few problems with this, specifically, here:
http://www.hibernate.org/hib_docs/v3/re ... ersistence

More precisely:

Quote:
The value of the action argument is set on the command line when calling the target:

C:\hibernateTutorial\>ant run -Daction=store

You should see, after compilation, Hibernate starting up and, depending on your configuration, lots of log output. At the end you will find the following line:
[java] Hibernate: insert into EVENTS (EVENT_DATE, title, EVENT_ID) values (?, ?, ?)


When I use ant, I receive this:
Quote:
C:\James' Stuff\Programs\eclipse\workspace\DB>ant run -Daction=store
Buildfile: build.xml

clean:
[delete] Deleting directory C:\James' Stuff\Programs\eclipse\workspace\DB\bin
[mkdir] Created dir: C:\James' Stuff\Programs\eclipse\workspace\DB\bin

copy-resources:
[copy] Copying 6 files to C:\James' Stuff\Programs\eclipse\workspace\DB\bin

compile:

run:
[java] java.lang.NoClassDefFoundError: src/events/EventManager
[java] Exception in thread "main"
[java] Java Result: 1

BUILD SUCCESSFUL
Total time: 1 second


When I use eclipse I receive the stack trace printed above.

This is how my directories are set up and what is in them:



Code:
+lib
  antlr.jar
  cglib.jar
  asm.jar
  asm-attrs.jars
  commons-collections.jar
  commons-logging.jar
  hibernate3.jar
  jta.jar
  dom4j.jar
  postgresql-8.0-311.jdbc3.jar
+src
  hibernate.cfg.xml
  log4j.properties
  +events
    Event.java
    Event.class
    Event.hbm.xml
    EventManager.java
    EventManager.class
  +util
    HibernateUtil.java
    HibernateUtil.class
+data
+bin
   copies of the src directory (this is made when ant is ran)
build.xml
hibernate.properties


I am not knowledgable in databases so I am not entirely sure what is causing this problem. I know my database is working. I have used navicat to go in and modify the contents of it. While in pgadmin 3, I make sure it is connected.

When I run ant and eclipse, I get 2 different error messages.
with ant: it cannot seem to create a class that doesn't exist (makes sense, but it doesn't give me enough information to try and fix this).
with eclipse: it cannot find the hibernate.cfg.xml. HOWEVER, in the previous messages as it runs indicates that it did find it!:
Quote:
Jan 29, 2006 2:59:47 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jan 29, 2006 2:59:47 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Initial SessionFactory creation failed. org.hibernate.HibernateException: /hibernate.cfg.xml not found


I have went over the tutorial several times and went to FAQ with the common problems but I haven't seen anyting that resembles mine. Finally, I have talked to one of my friends who has used hibernate somewhat before and even had him send me a working eclipse project that has used it. From that I thought I could find the differences, but he appears to have LESS hibernate files/stuff in his project then I do. I hope I have provided enough information to receive some assistance.

Thank you for your time.

EDIT:
My hibernate config file:

Code:
<?xml version="1.0" encoding="UTF-8" ?>
  <!DOCTYPE hibernate-configuration (View Source for full doctype...)>
- <hibernate-configuration>
- <session-factory>
  <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
  <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
  <property name="hibernate.connection.url">jdbc:postgresql://localhost/riesuts</property>
  <property name="hibernate.connection.password">dbtest</property>
  <property name="hibernate.connection.username">hibernate</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="src/events/Event.hbm.xml" />
  </session-factory>
  </hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 29, 2006 5:51 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Your main problem is that you are putting src as part of your package path. It isn't, so remove it from all package specifications. All class and xml files in src are (should be) copied to bin, and are looked for by your java VM relative to that directory. src isn't involved at that point.

Check your ant build.xml to ensure that it copies .xml files during the build process. Or you can verify this manually by confirming that the xml files are in the bin directory after build.

Ensure that the classpath you pass to the VM you're testing with is set up correctly. It needs to specify the bin directory.

You'll also have to remove "src/" from the mapping resource line in your .cfg.xml file. Resources will be looked for relative to the bin directory.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 3:28 am 
Newbie

Joined: Sun Jan 29, 2006 3:37 am
Posts: 10
I want to thank you for your reply! It has been helpful and I am fixing some other errors that I have done. I hope to have it working in a few days and if not I will reply to this thread.

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 4:42 pm 
Newbie

Joined: Sun Jan 29, 2006 3:37 am
Posts: 10
I have returned, with some success!

I have managed to get the tutorial to work fine. I decided it'd be better if I used the DB that used. That worked. Thanks for the help there.

The DB that I want to use is postgres 8.1.2 (I decided to get the upgrade to see if that changed anything) though, so I have been trying to get postgres to work with the tutorial. However, this isn't working. I am getting an error that I do not understand.

Here is the stack trace:
Quote:
15:53:04,781 INFO Environment:479 - Hibernate 3.1
15:53:04,796 INFO Environment:509 - hibernate.properties not found
15:53:04,796 INFO Environment:525 - using CGLIB reflection optimizer
15:53:04,796 INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
15:53:04,890 INFO Configuration:1286 - configuring from resource: /hibernate.cfg.xml
15:53:04,890 INFO Configuration:1263 - Configuration resource: /hibernate.cfg.xml
15:53:05,093 INFO Configuration:468 - Reading mappings from resource: events/Event.hbm.xml
15:53:05,250 INFO HbmBinder:265 - Mapping class: events.Event -> EVENTS
15:53:05,296 INFO Configuration:1397 - Configured SessionFactory: null
15:53:05,296 INFO Configuration:1022 - processing extends queue
15:53:05,296 INFO Configuration:1026 - processing collection mappings
15:53:05,296 INFO Configuration:1035 - processing association property references
15:53:05,296 INFO Configuration:1057 - processing foreign key constraints
15:53:05,390 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
15:53:05,390 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
15:53:05,406 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
15:53:05,406 INFO DriverManagerConnectionProvider:80 - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost/test
15:53:05,406 INFO DriverManagerConnectionProvider:86 - connection properties: {user=hibernate, password=****}
15:53:05,593 INFO SettingsFactory:77 - RDBMS: PostgreSQL, version: 8.1.2
15:53:05,609 INFO SettingsFactory:78 - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.1 JDBC3 with SSL (build 404)
15:53:05,625 INFO Dialect:103 - Using dialect: org.hibernate.dialect.PostgreSQLDialect
15:53:05,640 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
15:53:05,640 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
15:53:05,640 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
15:53:05,656 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
15:53:05,656 INFO SettingsFactory:136 - JDBC batch size: 15
15:53:05,656 INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
15:53:05,656 INFO SettingsFactory:144 - Scrollable result sets: enabled
15:53:05,656 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
15:53:05,656 INFO SettingsFactory:160 - Connection release mode: auto
15:53:05,656 INFO SettingsFactory:187 - Default batch fetch size: 1
15:53:05,656 INFO SettingsFactory:191 - Generate SQL with comments: disabled
15:53:05,656 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
15:53:05,656 INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
15:53:05,656 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
15:53:05,671 INFO SettingsFactory:203 - Query language substitutions: {}
15:53:05,671 INFO SettingsFactory:209 - Second-level cache: enabled
15:53:05,671 INFO SettingsFactory:213 - Query cache: disabled
15:53:05,671 INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.NoCacheProvider
15:53:05,671 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
15:53:05,671 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
15:53:05,671 INFO SettingsFactory:257 - Echoing all SQL to stdout
15:53:05,687 INFO SettingsFactory:264 - Statistics: disabled
15:53:05,687 INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
15:53:05,687 INFO SettingsFactory:283 - Default entity-mode: pojo
15:53:05,734 INFO SessionFactoryImpl:153 - building session factory
15:53:06,218 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
15:53:06,218 INFO SessionFactoryImpl:353 - Checking 0 named HQL queries
15:53:06,218 INFO SessionFactoryImpl:373 - Checking 0 named SQL queries
new session factory.
Session: SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
Hibernate: select nextval ('hibernate_sequence')
15:53:06,406 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 42P01
15:53:06,406 ERROR JDBCExceptionReporter:72 - ERROR: relation "hibernate_sequence" does not exist
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not get next sequence value
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:96)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:91)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:544)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:533)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:529)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:292)
at $Proxy0.save(Unknown Source)
at events.EventManager.createAndStoreEvent(EventManager.java:47)
at events.EventManager.main(EventManager.java:21)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "hibernate_sequence" does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1512)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1297)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:430)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:346)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:250)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:75)
... 17 more



Here is my hibernate config file:
Code:
<?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.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="hibernate.connection.url">jdbc:postgresql://localhost/test</property>
        <property name="hibernate.connection.password">dbtest</property>
        <property name="hibernate.connection.username">hibernate</property>

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

        <!-- SQL dialect -->
      <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</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>


I know the DB is up as I am logged in with pgAdmin.

Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 6:36 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Sorry, I've never used Postgres or sequences. The tutorials works fine with SQLServer if I change sequences to identities.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 6:40 pm 
Newbie

Joined: Sun Jan 29, 2006 3:37 am
Posts: 10
I managed to figure out that I have to create a sequence and have done so. Now I am getting another error:

Quote:
Session: SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
Hibernate: select nextval ('hibernate_sequence')
Hibernate: insert into EVENTS (EVENT_DATE, EVENT_TITLE, EVENT_ID) values (?, ?, ?)
17:51:54,093 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: null
17:51:54,093 ERROR JDBCExceptionReporter:72 - Batch entry 0 insert into EVENTS (EVENT_DATE, EVENT_TITLE, EVENT_ID) values (2006-01-30 17:51:52.218000 -0500, My Event, 14) was aborted. Call getNextException to see the cause.
17:51:54,093 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 42703
17:51:54,109 ERROR JDBCExceptionReporter:72 - ERROR: column "event_date" of relation "events" does not exist
17:51:54,109 ERROR AbstractFlushingEventListener:299 - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update


So, it looks like it cannot find the table. I went into the DB with navicat and made the table, but, it doesn't seem to still work.

Config for Events:

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">
         <param name="sequence">hibernate_sequence</param>
            </generator>
        </id>
        <property name="date" type="timestamp" column="EVENT_DATE"/>
        <property name="title" column = "EVENT_TITLE"/>
    </class>

</hibernate-mapping>


Hibernate config:
Code:
<?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.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="hibernate.connection.url">jdbc:postgresql://localhost/test</property>
        <property name="hibernate.connection.password">dbtest</property>
        <property name="hibernate.connection.username">hibernate</property>

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

        <!-- SQL dialect -->
      <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</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>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 7:14 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You created table EVENTS, on server localhost, in database test, in schema dbo? With the correct three columns? You should be able to issue this sql from your SQL console (navicat?):
Code:
use master
insert into test.dbo.events (event_title) values ('Test event')
select * from test.dbo.events

You shouldn't need to insert an id (it's a sequence, generated by the server, I presume) or a date (it's a timestamp, definitely generated by the server).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 7:26 pm 
Newbie

Joined: Sun Jan 29, 2006 3:37 am
Posts: 10
When I go into the console for the DB, nothing happens when I do that:

-> use master
insert into test.public.events (event_title) values ('Test event')
select * from test.public.events
->

The scehema is public, not dbo.

The overall structure is this:
Code:
localhost
       test
                public
                          tables/reports/etc


I can, however, add entries to the table via navicat no problem.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 7:40 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Did you use SQL in navicat (I don't know what navicat is: if you're adding a row using a GUI of some sort, it isn't reallly verifying that the SQL equivalent will work)? If you can add the row using SQL, next thing to try is to use exactly the SQL that hibernate is generating:
Code:
select nextval ('hibernate_sequence')
Hibernate: insert into EVENTS (EVENT_DATE, EVENT_TITLE, EVENT_ID) values (?, ?, ?)

Obviously you have to replace the ?s with the correct values.

If that doesn't work then you've found your problem. Find out what does work and tweak your mapping so that hibernate generates the correct SQL. For example, some servers will not allow timestamp values to be specified, they insist on generating them themselves. If that's the case for you, you can just add insert="false" update="false" on the timestamp property, or change timestamp to datetime.

If hibernate's SQL is working when you use it through navicat, then all I can suggest is to trace into the code and find where hibernate's view of the world differs from navicat's. The schema might be an issue, though I presume that "public" is the default schema for Postgres. Possibly the dbtest user doesn't have permissions in the public schema, or for the EVENTS table.

I can't think of other potential issues right now, but maybe I'll come up with something after lunch...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 2:01 am 
Newbie

Joined: Sun Jan 29, 2006 3:37 am
Posts: 10
Hello!

I did what you said and this is what I discovered:

1.) I can make the table in pgadmin 3 (the administrative program for postgres) and put in the fields there. They HAVE to be lower case....then I run my queries on it and it works.

THEN I run my program in eclipse - and it works.

One thing though - it does not like the date that it is timestamped. But, I will not really be using dates in my real program (maybe once so I'll figure it out after I get the thing to really work) so I don't care about that.

So I removed the date stuff for the DB. All Gravy there.

2.) I then delete my table and rerun (with the date stuff removed) and I get the message that it can't find my events table.

This leads me to believe that for whatever reason, Hibernate is not generating the tables when I execute my program.

I believe that this line in my config should create the DB:
<!-- Drop and re-create the database schema on startup
<property name="hbm2ddl.auto">create</property> -->


So, thinking more, it seems that perhaps, there is something with postgres creating schema's or something similiar. The output when the program executes does not indicate any problems with creating it so I do not know why its not working.

Progress being made...slowly.

EDIT:

I think I figured it out. My schema does not have any priveledges set, so, it cannot make new tables/etc. HOWEVER, it will work fine when I make the table in pgadmin. I just set the priveledges right? NOPE! Pgadmin has a bug (it appears to be one) that wont save the priveledges. I set them, and then, I click OK, and hit close. After, I reopen the prop. box and what do ya know....it doesn't have what I just set. So I'm off to go use MySql 5 instead :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 4:41 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Apologies if you know this already, I have no idea how XML savvy you are. If you're running that hbm2ddl line verbatim, then nothing will happen: it's commented out. Move the "-->" up one line, to after "startup".

The reason you couldn't get timestamp to work is probably because timestamp isn't exactly what you think it is. SQL timestamps are like versions, sequences or identities: they're managed by the server, and used as a "time of last update" or "time of row creation" field. To store an application-managed date or time in the DB, you must use datetime fields, not timestamp fields.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 4:57 pm 
Newbie

Joined: Sun Jan 29, 2006 3:37 am
Posts: 10
lol actually that WAS the problem....

however...there are 2 things that prevented me from noticing the comment

1.) in eclipse the code window is smaller so i had to scroll over to see the comment, so everytime i looked at it, i missed it!!

2.) i dont have a color plugin installed on eclipse, so XML looks the same.

i feel like an idiot now LOL!! but hey, at least my DB works!!


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