Re: Driver matching with SDriver.driverName
[email protected] Mon, 28 Sep 2009 17:15:25 +1000
| Newsgroups | gmane.comp.java.orm.simpleorm |
|---|---|
| Message-ID | <[email protected]> |
PS. You will also probably need to change
SDriver.retrieveInsertedKey
Which is called by
theGenerator.postUpdateWithGeneratedKey(session, instance);
See HSQL.
Anthony
At 05:11 PM 28/09/2009, you wrote:
>Hello Ryan,
>
>Could do. But for now just create subclasses for the different variants. I suggest just use a static class for these trivial bits. There may even be some real differences later.
>
>(The bigger problem is that SDrivers represent both the instance and the factory. Should be a small static factory class for the factory. Just has never got to the top of the list to fix.)
>
>It would be very good to support Deryb/JavaDB. (I'm not clear about the difference?). This is long overdue. And it should build and run Derby out of the JDK 1.6 directly, with their jars. Maybe even make Derby the default test DB instead of HSQL?
>
>The normal way to handle database inconsistencies is to delegate them to some method in the SDriver hierarchy. Null works for MSSQL and HSQL.
>
>In SSessionJdbcHelper.flush you would have to change
> if (value == null && fieldMeta.isPrimary() && theGenerator==null)
> throw new SException.Error("Null primary key not set (after createWithNullKey) " + instance);
> fieldMeta.writeFieldValue(ps, jx, instance.getRawArrayValue(fieldMeta));
>
>into something like
>
> if (value == null && fieldMeta.isPrimary())
> if (theGenerator==null)
> throw new SException.Error("Null primary key not set (after createWithNullKey) " + instance);
> else
> session.getDriver().setEmptyGeneratedKey() // Or maybe just do nothing here?
> else
> fieldMeta.writeFieldValue(ps, jx, instance.getRawArrayValue(fieldMeta));
>
>Make sure that whatever you do continues to work for at least HSQL, the default test case.
>
>Send me any changed files and I'll diff and check them in. You are welcome to become a committer if you make serious contributions.
>
>There is no magic in the code. You are not dependent on us to change things, unlike more complex systems.
>
>Regards,
>
>Anthony
>
>
>>I'm trying to get identity generation on insert working with Derby. I have the driver set up so it creates the table with GENERATED BY DEFAULT AS IDENTITY for my identity field and it works fine. The problem occurs when I call session.ses.createWithGeneratedKey and then try to commit the new record. SimpleORM tries to call insert passing null for the identity field. Derby accepts an insert statement that either 1) doesn't specify a value for the identity column or 2) passes the value "default" for the identity column. Derby throws an error when SimpleORM tries to pass null for the generated column.
>>
>>How should I handle this? If there's no way then I'll have to change SimpleORM code to pass "default" instead of "null" but I'd prefer not to do that.
>
>
>At 01:00 PM 27/09/2009, you wrote:
>>
>>
>>Hi.
>>
>>Have you considered allowing 1 SimpleORM driver to handle multiple JDBC drivers? Instead of using driverName and comparing the returned string to choose a SimpleORM driver, you could pass the actual driver name into a boolean method of an SDriver subclass and let the driver itself decide whether it's a match. For example, I'm working with an embedded Derby database and the driver name is "Apache Derby Embedded JDBC Driver" but the driver name for the network client would be "Apache Derby Network Client JDBC Driver". The same SimpleORM driver would probably work for both.
>>
>>Just curious,
>>--
>>Ryan Boder
>>1 614 598 6339
>>
>
>Dr Anthony Berglas, [email protected] Mobile: +61 4 4838 8874
>Just because it is possible to push twigs along the ground with ones nose
>does not necessarily mean that is the best way to collect firewood.
Dr Anthony Berglas, [email protected] Mobile: +61 4 4838 8874
Just because it is possible to push twigs along the ground with ones nose
does not necessarily mean that is the best way to collect firewood.
------------------------------------
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:
mailto:[email protected]
mailto:[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/