|
Hi,
I am implementing on Oracle 9i and trying to use a sequence: I have: -------------- Lijst.groovy ------------- class Lijst { Long id String description String toString() { "${this.class.name} : $id" } boolean equals(other) { if(other?.is(this))return true if(!(other instanceof Lijst)) return false if(!id || !other?.id || id!=other?.id) return false return true } int hashCode() { int hashCode = 0 hashCode = 29 * (hashCode + ( !id ? 0 : id ^ (id >>> 32) ) ) } } ---------------------------------------- ------ lijst.hbn.xml ------------- <?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 schema="etst"> <class name="Lijst" table="lijst"> <id name="id" column="lijst_no" type="long"> <generator class="sequence"> lijst_seq </generator> </id> <property name="description" column="description" type="string" /> </class> </hibernate-mapping> ------------------------------------------------ --------- lijst.sql ---------------------- ALTER SESSION SET CURRENT_SCHEMA=ETST; drop table ETST.lijst; create table ETST.lijst ( lijst_no number(8, 0), description varchar2(30) ); drop sequence lijst_seq; create sequence lijst_seq start with 1 increment by 1 nomaxvalue; drop public synonym lijst_seq; create public synonym lijst_seq for etst.lijst_seq; ---------------------------------------- When starting up Grails-0.3 snapshow downloaded today I get: ... [groovy] table not found: etst.lijst_seq ... [groovy] Context initialization failed [groovy] org.springframework.beans.factory.BeanCreationException: Error creat ing bean with name 'sessionFactory' defined in null: Initialization of bean fail ed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 2 [groovy] java.lang.ArrayIndexOutOfBoundsException: 2 [groovy] at org.hibernate.tool.hbm2ddl.DatabaseMetadata.isTable(DatabaseM etadata.java:147) [groovy] at org.hibernate.cfg.Configuration.validateSchema(Configuration. java:975) [groovy] at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaVal idator.java:116) [groovy] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryIm pl.java:296) [groovy] at org.hibernate.cfg.Configuration.buildSessionFactory(Configura tion.java:1176) It is looking for a table "lijst_seq" instead of a sequence? The sequence is working when selecting from DUAL. Any ideas on how to proceed? thanks, Peter |
|
As you're using Hibernate mapping I would say you need to send this
message to the Hibernate list as the exception occurs during Hibernate's hbm2ddl utility and is not originating from Grails code. The fact that you're using a Groovy class is irrelevant as far as Hibernate is concerned it is a Java class Graeme On 8/20/06, meetlint <[hidden email]> wrote: > > Hi, > > I am implementing on Oracle 9i and trying to use a sequence: > > I have: > -------------- Lijst.groovy ------------- > class Lijst { > Long id > String description > > > String toString() { "${this.class.name} : $id" } > > boolean equals(other) { > if(other?.is(this))return true > if(!(other instanceof Lijst)) return false > > if(!id || !other?.id || id!=other?.id) return false > > return true > } > > int hashCode() { > int hashCode = 0 > hashCode = 29 * (hashCode + ( !id ? 0 : id ^ (id >>> 32) ) ) > } > } > ---------------------------------------- > ------ lijst.hbn.xml ------------- > <?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 schema="etst"> > <class name="Lijst" table="lijst"> > <id name="id" column="lijst_no" type="long"> > <generator class="sequence"> > <param name="sequence">lijst_seq</param> > </generator> > > </id> > <property name="description" column="description" type="string" /> > </class> > </hibernate-mapping> > ------------------------------------------------ > --------- lijst.sql ---------------------- > ALTER SESSION SET CURRENT_SCHEMA=ETST; > > drop table ETST.lijst; > > create table ETST.lijst ( > lijst_no number(8, 0), > description varchar2(30) > ); > > drop sequence lijst_seq; > create sequence lijst_seq > start with 1 > increment by 1 > nomaxvalue; > > drop public synonym lijst_seq; > create public synonym lijst_seq for etst.lijst_seq; > ---------------------------------------- > > When starting up Grails-0.3 snapshow downloaded today I get: > ... > [groovy] table not found: etst.lijst_seq > ... > [groovy] Context initialization failed > [groovy] org.springframework.beans.factory.BeanCreationException: Error > creat > ing bean with name 'sessionFactory' defined in null: Initialization of bean > fail > ed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 2 > [groovy] java.lang.ArrayIndexOutOfBoundsException: 2 > [groovy] at > org.hibernate.tool.hbm2ddl.DatabaseMetadata.isTable(DatabaseM > etadata.java:147) > [groovy] at > org.hibernate.cfg.Configuration.validateSchema(Configuration. > java:975) > [groovy] at > org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaVal > idator.java:116) > [groovy] at > org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryIm > pl.java:296) > [groovy] at > org.hibernate.cfg.Configuration.buildSessionFactory(Configura > tion.java:1176) > > It is looking for a table "lijst_seq" instead of a sequence? > > The sequence is working when selecting from DUAL. > > Any ideas on how to proceed? > > thanks, > Peter > > -- > View this message in context: http://www.nabble.com/grails-sequence-tf2136686.html#a5896506 > Sent from the grails - user forum at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by meetlint
Hi,
another way to use sequence for Postgresql or Oracle users. I wrote blog about using sequence in Grails GORM by customizing Grails source code. http://xmldo.blogspot.com/2006/08/using-sequence-in-grails-gorm.html Regards, T.Yamamoto On 8/21/06, meetlint <[hidden email]> wrote: > > Hi, > > I am implementing on Oracle 9i and trying to use a sequence: > > I have: > -------------- Lijst.groovy ------------- > class Lijst { > Long id > String description > > > String toString() { "${this.class.name} : $id" } > > boolean equals(other) { > if(other?.is(this))return true > if(!(other instanceof Lijst)) return false > > if(!id || !other?.id || id!=other?.id) return false > > return true > } > > int hashCode() { > int hashCode = 0 > hashCode = 29 * (hashCode + ( !id ? 0 : id ^ (id >>> 32) ) ) > } > } > ---------------------------------------- > ------ lijst.hbn.xml ------------- > <?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 schema="etst"> > <class name="Lijst" table="lijst"> > <id name="id" column="lijst_no" type="long"> > <generator class="sequence"> > <param name="sequence">lijst_seq</param> > </generator> > > </id> > <property name="description" column="description" type="string" /> > </class> > </hibernate-mapping> > ------------------------------------------------ > --------- lijst.sql ---------------------- > ALTER SESSION SET CURRENT_SCHEMA=ETST; > > drop table ETST.lijst; > > create table ETST.lijst ( > lijst_no number(8, 0), > description varchar2(30) > ); > > drop sequence lijst_seq; > create sequence lijst_seq > start with 1 > increment by 1 > nomaxvalue; > > drop public synonym lijst_seq; > create public synonym lijst_seq for etst.lijst_seq; > ---------------------------------------- > > When starting up Grails-0.3 snapshow downloaded today I get: > ... > [groovy] table not found: etst.lijst_seq > ... > [groovy] Context initialization failed > [groovy] org.springframework.beans.factory.BeanCreationException: Error > creat > ing bean with name 'sessionFactory' defined in null: Initialization of bean > fail > ed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 2 > [groovy] java.lang.ArrayIndexOutOfBoundsException: 2 > [groovy] at > org.hibernate.tool.hbm2ddl.DatabaseMetadata.isTable(DatabaseM > etadata.java:147) > [groovy] at > org.hibernate.cfg.Configuration.validateSchema(Configuration. > java:975) > [groovy] at > org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaVal > idator.java:116) > [groovy] at > org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryIm > pl.java:296) > [groovy] at > org.hibernate.cfg.Configuration.buildSessionFactory(Configura > tion.java:1176) > > It is looking for a table "lijst_seq" instead of a sequence? > > The sequence is working when selecting from DUAL. > > Any ideas on how to proceed? > > thanks, > Peter > > -- > View this message in context: http://www.nabble.com/grails-sequence-tf2136686.html#a5896506 > Sent from the grails - user forum at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > -- ---------------- T.Yama --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
