-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate + Postgres + native id = AUTO_INCREMENT sadness?
PostPosted: Wed Feb 11, 2004 10:12 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
Any idea why I am getting the following when I try to run our hibernate app on linux against Postgres 7.4.1?

Code:
[RMI TCP Connection(6)-10.0.0.205] [2004-02-11 18:05:44,328] INFO   - hibernate.database=postgres
[RMI TCP Connection(6)-10.0.0.205] [2004-02-11 18:05:44,376] DEBUG  - Creating Hibernate configuration from prop resource hibernate_ejb_postgres.properties
[RMI TCP Connection(6)-10.0.0.205] [2004-02-11 18:05:45,452] DEBUG  - Configured Hibernate configuration
[RMI TCP Connection(6)-10.0.0.205] [2004-02-11 18:05:47,209] ERROR  - Unsuccessful: create table Task (id BIGINT NOT NULL AUTO_INCREMENT, class VARCHAR(255) not null, startRecord INTEGER, endRecord INTEGER, status SMALLINT, job_id BIGINT not null, sourcelist_id BIGINT, primary key (id))
[RMI TCP Connection(6)-10.0.0.205] [2004-02-11 18:05:47,209] ERROR  - ERROR: syntax error at or near "AUTO_INCREMENT"

[RMI TCP Connection(6)-10.0.0.205] [2004-02-11 18:05:47,212] ERROR  - Unsuccessful: create table Campaign (id BIGINT NOT NULL AUTO_INCREMENT, name VARCHAR(255), client_id BIGINT not null, primary key (id))
[RMI TCP Connection(6)-10.0.0.205] [2004-02-11 18:05:47,212] ERROR  - ERROR: syntax error at or near "AUTO_INCREMENT"


And so forth and so on....

This is with the pg74.1jdbc3.jar Postgres driver, and this Hibernate configuration:

Code:
hibernate.connection.datasource     jdbc_1
hibernate.dialect                   net.sf.hibernate.dialect.MySQLDialect
hibernate.show_sql                  false
hibernate.transaction.factory_class net.sf.hibernate.transaction.JTATransactionFactory
jta.UserTransaction                 java:comp/UserTransaction
hibernate.jdbc.batch_size           0
hibernate.hbm2ddl.auto              create


We are using the following app server data source configuration:

Code:
datasource.name         jdbc_1
datasource.url          jdbc:postgresql://barracuda3/barracuda_test
datasource.classname    org.postgresql.Driver
datasource.username     postgres
datasource.password     
datasource.mapper   rdb.postgres


If I run the following SQL against the database by hand (using DbVisualizer 4.03 -- love it! -- and the exact same driver and jdbc URL), I get the same error:

create table Campaign (id BIGINT NOT NULL AUTO_INCREMENT, name VARCHAR(255), client_id BIGINT not null, primary key (id))

But sure enough, *this* SQL succeeds:

create table Campaign (id BIGINT NOT NULL, name VARCHAR(255), client_id BIGINT not null, primary key (id))

Here's the mapping:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
    PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

    <class name="com.nimblefish.core.data.Campaign">

        <id name="id" type="long" unsaved-value="null" >
            <generator class="native"/>
        </id>

        <property name="name" type="string"/>

        <many-to-one name="client" column="client_id" not-null="true"
            class="com.nimblefish.core.data.Client"/>

        <set name="sourceLists" inverse="true" cascade="all-delete-orphan" lazy="true">
            <key column="campaign_id"/>
            <one-to-many class="com.nimblefish.core.data.SourceList"/>
        </set>

        <set name="campaignLists" inverse="true" cascade="all-delete-orphan" lazy="true">
            <key column="campaign_id"/>
            <one-to-many class="com.nimblefish.core.data.CampaignList"/>
        </set>

        <set name="workRequests" inverse="true" cascade="all-delete-orphan" lazy="true">
            <key column="campaign_id"/>
            <one-to-many class="com.nimblefish.core.data.WorkRequest"/>
        </set>

        <!-- don't set inverse="true" on lists since the parent needs to maintain the index! -->
        <list name="jobDescriptions" cascade="all-delete-orphan" lazy="true">
            <key column="campaign_id"/>
            <index column="campaign_index"/>
            <one-to-many class="com.nimblefish.core.data.JobDescription"/>
        </list>

    </class>

</hibernate-mapping>


What simple, obvious, brain-deadeningly clear thing am I, a newbie, missing?

Thanks very much --
cheers! --
Rob


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 10:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
hibernate.dialect net.sf.hibernate.dialect.MySQLDialect


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 2:35 am 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
My embarrassment and mortification knows no bounds.

I am going to have to get that hbm2java patch submitted this weekend to make up for my idiocy.....

(And taking Gavin's time, of all people, with such trivialities? sigh!)
thanks--
cheers--
Rob


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