I don't need help, but am just making an observation.
This is a continuation of the Topic I found on this problem:
GENERATING SEQUENCES
I have a PostgreSQL database with several Schemas. The reason for the different Schemas is that PostgreSQL will allow me to define the specific location of the various Schemas (which Linux or Hard Drive partition I have them on), but no matter.
I have a schema called
stocks under my PostgreSQL database. I have my stock information and ticker information in that schema.
When I initially tried to save records to a table in that schema, I was getting an exception stating that the
hibernate_sequence could not be found. This is even though I had defined it in that schema. This seemed odd, since in my previous tests with tables in the
public schema of another database, there had been no problem.
So, I created an
hibernate_sequence under the
public schema of this database.
Low and behold it worked!!!! BUT!!!! I did not want to use a sequence in the
public schema. I wanted it under the
stocks schema.
So, I created a sequence called
exchangeid_seq under my
stocks schema AND used a modified
Exchange.hbm.xml file that defined the generator like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Feb 21, 2009 9:30:23 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="org.scawa.stockandtrade.pojo.Exchange" schema="stocks" table="exchange">
<id name="id" type="int">
<column name="id"/>
<generator class="sequence">
<param name="sequence">stocks.exchangeid_seq</param>
</generator>
</id>
<property name="name" type="string">
<column length="10" name="name" not-null="true"/>
</property>
<property name="description" type="string">
<column length="60" name="description"/>
</property>
<property name="dateCreated" type="timestamp">
<column length="29" name="date_created" not-null="true"/>
</property>
<property name="dateTerminated" type="timestamp">
<column length="29" name="date_terminated"/>
</property>
</class>
</hibernate-mapping>
When I qualified the location of the sequence under my
stocks schema, it worked again.
My observation is this..... Hibernate seems to be handling Postgres
hibernate_sequence incorrectly. It seems to ignore the schema definition as defined in the
..hbm.xml file.
Or is there a way to define which schema that Hibernate will look in for the sequence generator?
Any comments are welcomed and desired.
Stephen McConnell
"First appearances can be deceiving. But then so can second and third glances when you already have an agenda."
-- Lamar Stephens