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: Bigserial and PostGIS
PostPosted: Tue May 12, 2009 7:01 am 
Beginner
Beginner

Joined: Thu Feb 19, 2009 5:48 am
Posts: 37
Location: Glasgow, Scotland
I'm trying to get my table ids to use pre written sequences when the table schemas are generated by hibernate but they only ever get defined as bigints using the default hibernate_sequence

Code:
   <class name="edina.clive.domain.Layer" table="layers" dynamic-insert="true" dynamic-update="true">
    <meta attribute="class-description">
      A layer object which holds a list of layer sub-objects and a list of Style names in place of a style object
    </meta>
      <id name="layerID" type="long" unsaved-value="null">
         <generator class="sequence">
            <param name="sequence">layer_layerid_seq</param>
         </generator>
      </id>
        <property name="layerName" lazy="false" unique="true" type="string" length="64"/>
        <property name="layerTitle" lazy="false" not-null="true" type="string" length="128"/>
      <property name="srs" column="layerSRS" type="string" length="32" lazy="false" /> <!-- auto generated from geometry? -->
      <property name="minimumScale" column="layerscalemin" lazy="false" />
      <property name="maximumScale" column="layerscalemax" lazy="false" />
      
<!-- Cannot test on HSQLDB as it is not spatial, this will enter bounding box as text for testing -->
<!--   <property name="boundingBox" type="edina.clive.domain.hibernate.EnvelopeUserType" />-->
       <property name="boundingBoxGeometry" type="org.hibernatespatial.GeometryUserType" />
      
       <property name="subLayers" type="edina.clive.domain.hibernate.SubLayerUserType" lazy="false"/>
      
<!-- it may be possible to do this the originally intended way (having two comma separated fields in the Layer table and building from them) -->
       <set name="styles" table="STYLES" cascade="save-update" lazy="false">
         <key column="layerID"  />
          <one-to-many class="edina.clive.domain.Style" />
       </set>
    </class>


Code:
CREATE TABLE layers
(
  layerid bigint NOT NULL,
  ...
)


I want...

Code:
CREATE TABLE layers
(
  layerid bigint NOT NULL DEFAULT NEXTVAL('layers_layerid_seq'),
  ...
)


Why isn't Hibernate picking up the sequences when I'm hard coding them in?

_________________
##############################
If I helped, rate my comment, I have plenty of stupid questions to ask that I need credit for ;)
##############################


Top
 Profile  
 
 Post subject: Re: Bigserial and PostGIS
PostPosted: Tue May 12, 2009 8:26 am 
Beginner
Beginner

Joined: Thu Feb 19, 2009 5:48 am
Posts: 37
Location: Glasgow, Scotland
Is there any way perhaps to alter the schema generation then to include the default value statement?

_________________
##############################
If I helped, rate my comment, I have plenty of stupid questions to ask that I need credit for ;)
##############################


Top
 Profile  
 
 Post subject: Re: Bigserial and PostGIS
PostPosted: Tue May 12, 2009 11:00 am 
Beginner
Beginner

Joined: Thu Feb 19, 2009 5:48 am
Posts: 37
Location: Glasgow, Scotland
I've tested this extensibly now and if I set up the schema by hand it all works fine but I need Hibernate to generate this schema for automated tests.
I simply need hibernate to generate
Code:
layerid bigint NOT NULL DEFAULT NEXTVAL('layers_layerid_seq'),

_________________
##############################
If I helped, rate my comment, I have plenty of stupid questions to ask that I need credit for ;)
##############################


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.