Re: MySql driver code

[email protected] Mon, 14 Jun 2010 19:23:29 +1000
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
To clarify, Harry, could you please test your code for a completely empty table.  Also please confirm that the supplied test cases work with your patch on MySQL.

Thanks for the contribution,

Anthony

At 05:59 PM 11/06/2010, Franck Routier wrote:
>  
>
>Hi,
>
>thanks for this. I had a look on the other drivers that implement this,
>and they return 0 on null result.
>
>Is this something we would want to do for MySql ?
>
>Franck
>
>Le vendredi 11 juin 2010 à 07:17 +0000, hkara1 a écrit :
>> 
>> Hi,
>> 
>> I am using simpleorm with MySql for a project, and I was surprised
>> to see that the SDriverMySql does not handle "insert key generation"
>> though this is mentioned in the docs.
>> 
>> here is what I added to make it work :
>> 
>> @Override
>> public boolean supportsInsertKeyGeneration() { return true; }
>> 
>> @Override
>> protected long retrieveInsertedKey(SRecordMeta<?> rec, SFieldScalar
>> keyFld) 
>> {
>> Object lastInsertIdObj = getSession().rawQuerySingle("SELECT
>> LAST_INSERT_ID()", false);
>> if (lastInsertIdObj instanceof Number) {
>> Number lastInsertId = (Number) lastInsertIdObj;
>> return lastInsertId.longValue();
>> }
>> else {
>> throw new SException.Error("Not a number : " + lastInsertIdObj);
>> }
>> }
>> 
>> Hope it helps,
>> 
>> Harry Karadimas
>> 
>> 
>> 
>> 
>> 
>
>


Spreadsheet Detective,
Southern Cross Software Queensland Pty Limited
54 Gerler Street
Bardon, Queensland 4065, Australia.

Email: [email protected]
www.SpreadsheetDetective.com
Ph: +61 427 830248 (Australian Eastern Standard Time)

"If the model seems correct only because the numbers look right, 
then why build the model in the first place?"



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

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/