Problem with SSessionJdbc.create()

Mike Goodwin <[email protected]> Sun, 11 Apr 2010 23:48:50 +0100
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
Hi,

I found the following test does not work (SimpleORM 3.11), the last
create throws an exception. Changing from create() to findOrCreate()
makes it work. Code below,

thanks,

mike



package dev.scratch;

import static simpleorm.dataset.SFieldFlags.
SPRIMARY_KEY;
import java.sql.Connection;
import java.util.List;
import simpleorm.dataset.SFieldString;
import simpleorm.dataset.SRecordInstance;
import simpleorm.dataset.SRecordMeta;
import simpleorm.sessionjdbc.SSessionJdbc;

public class TestCreate {
    static public class A extends SRecordInstance{
        static public final SRecordMeta<A> META = new SRecordMeta(A.class, "A");
        static final public SFieldString K = new SFieldString(META,
"k", 256, SPRIMARY_KEY);

        public SRecordMeta<A> getMeta() { return META; };
    }

    static public class A2A extends SRecordInstance{
        static final public SRecordMeta<A2A> META = new
SRecordMeta(A2A.class, "B");

        static final public SFieldString A1 = new SFieldString(META,
"A1", 256, SPRIMARY_KEY);
        static final public SFieldString A2 = new SFieldString(META,
"A2", 256, SPRIMARY_KEY);

        public SRecordMeta<A2A> getMeta() { return META; };
    }

    static public void main(String[] args) throws Exception {
        Class.forName("org.hsqldb.jdbcDriver");
        Connection con =
java.sql.DriverManager.getConnection("jdbc:hsqldb:hsqlTempFiles;shutdown=true;",
"sa", "");
        SSessionJdbc ses = SSessionJdbc.open(con, "Tiny");

        ses.begin();
        ses.rawUpdateDB(ses.getDriver().createTableSQL(A.META));
        ses.rawUpdateDB(ses.getDriver().createTableSQL(A2A.META));
        ses.create(A.META, "1");
        ses.create(A.META, "2");
        ses.create(A2A.META, "1","2");
        ses.commit();
    }
}


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/SimpleORM/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/SimpleORM/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/