Anthony Berglas | 2 Dec 2008 01:05

Re: SimpleORM Download Form

Hello Martin,

The generator had not been upgraded to 3.0, so your work is much appreciated.  

meta.findOrCreate is now SSessionJDBC.findOrCreate and friends.  Before going too far with the
generator I suggest that you carefully read through ADemo.java to see the general flow.

I would prefer not to introduce dependencies to other packages such as Ant.  Make sure that the generator can
run as a simple main().  This can be simply called from Ant (possibly via a macro), or you could add an ant
wrapper in a separate, completely optional class.

When you are finished, send it to me and I will check it in.  

It should have a little self contained test case/example.  Eg. build the Employee/Department schema in
HSQL from the main tests, then reverse engineer it back with the tool.  If that is done I will be able to move it
from Extras to part of the main tool (in its own jar).

Also, please post your progress to the mailing list.

Thanks,

Anthony

At 08:29 PM 1/12/2008, you wrote:
>Hello,
>
>Thanks for the info. I have now looked a bit deeper into the code, and ran into some problems (most of which I
have fixed) :
>
>* I converted the generate-code into an ant-task (extending Task etc) to run from ant
(Continue reading)

Rickard Nilsson | 2 Dec 2008 08:20
Picon

session.create on a record with only one column fails

Hi,

I have found that if you try to create a record for a table that only  
has one column, you get an error (assertNewRow() fails). Has someone  
else experienced this?

   / Rickard Nilsson

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

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

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:SimpleORM-digest <at> yahoogroups.com 
    mailto:SimpleORM-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
(Continue reading)

Anthony & Melissa Berglas | 3 Dec 2008 04:10

Re: session.create on a record with only one column fails

SimpleORM traditionally did not allow key only tables at all, but Franck added that in.  Will have a look at
your single column example.

But it does seem very weird.  Even if you just want to note that something exists I would be inclined to add a
second boolean column anyway.  

Thanks for reporting it.

Anthony

At 05:20 PM 2/12/2008, you wrote:

>Hi,
>
>I have found that if you try to create a record for a table that only 
>has one column, you get an error (assertNewRow() fails). Has someone 
>else experienced this?
>
>/ Rickard Nilsson
>
>----------------------------------------------------------
>This message was sent using IMP, the Internet Messaging Program.
>
> 

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

(Continue reading)

Anthony Berglas | 3 Dec 2008 06:17

RE: SimpleORM Download Form

It is easy to create a generic method that will populate POJOs, see the mailing list

http://tech.groups.yahoo.com/group/SimpleORM/message/1675

Would not be that hard to create a dynamic proxy either -- a fun and project if anyone is interested. 

Do your other tools use Fields or Bean methods.  If the latter then you don't need to create POJOs at all -- just
the get and set methods.

The key though is to use the SDataSet/SRecordInstances directly for the other purposes.  Should only
require small wrappers.  SRecordInstances are much more powerful than POJOs because they can easily
store more information about each field then just its value.

Please post to the mailing list.

Anthony

At 10:17 AM 1/12/2008, you wrote:
>Anthony,
>
>Thankyou for your reply.
>
>In relation to your answer, let me explain. I have POJO domain objects
>that are used with multiple modes - to be used in memory(Java class), to
>be stored serializable in caches(Jdbm), to be stored in files as
>xml(xstream), to be stored/read from database (hibernate/Spring), as
>messages in web service calls(Jaxb).
>
>So these classes are annotated with annotations from the various
>frameworks I use.
(Continue reading)

Anthony Berglas | 9 Dec 2008 12:10

Re: Generator remake

Hello Martin,

I have checked in your code.  Made minor changes to build, move example to test.

Test task designed to run with simpleorm tests.  Compiles, but I cannot get Hsql to persist the db. 
Tomorrow's problem.

If you do any more work on this you MUST check out and work from that.  I do not want to have to merge changes.  You
should also create an account on Sourceforge for yourself and I can make you a committer, but just to work on
the generator at this stage.

Until the test works other issues can wait.  But what you have done looks good.

Thanks,

Anthony

At 08:20 PM 4/12/2008, you wrote:
>Hi Anthony,
>
>I am not yet member of the list, perhaps you can forward this mail ? 
>
>I started looking at SimpleORM to manage an existing database, which meant generating code.
Unfortunately, the generator code had not been upgraded to 3.0, so I had to start doing that. 
>
>So, I took a stab at it, and since it now produces compile:able code, it is at least marginally better than it
was before (it was defunct). Therefore, it makes sense to publish - but I would not call it 'finished', so
it's up to Anthony to decide to check it in or not.
>
>These are the changes : 
(Continue reading)

Martin Holst Swende | 9 Dec 2008 12:31
Picon

Re: Generator remake

Hi,

I will check out fresh and work from that from now on. I already have a sourceforge account, my username is Holiman.
 
Thanks,
/Martin

On December 9, 2008 at 12:10 PM Anthony Berglas <anthony <at> berglas.org> wrote:

> Hello Martin,
>
> I have checked in your code.  Made minor changes to build, move example to test.
>
> Test task designed to run with simpleorm tests.  Compiles, but I cannot get Hsql to persist the db.  Tomorrow's problem.
>
> If you do any more work on this you MUST check out and work from that.  I do not want to have to merge changes.  You should also create an account on Sourceforge for yourself and I can make you a committer, but just to work on the generator at this stage.
>
> Until the test works other issues can wait.  But what you have done looks good.
>
> Thanks,
>
> Anthony
>
>
> At 08:20 PM 4/12/2008, you wrote:
> >Hi Anthony,
> >
> >I am not yet member of the list, perhaps you can forward this mail ?
> >
> >I started looking at SimpleORM to manage an existing database, which meant generating code. Unfortunately, the generator code had not been upgraded to 3.0, so I had to start doing that.
> >
> >So, I took a stab at it, and since it now produces compile:able code, it is at least marginally better than it was before (it was defunct). Therefore, it makes sense to publish - but I would not call it 'finished', so it's up to Anthony to decide to check it in or not.
> >
> >These are the changes :
> >
> >    * I converted the generate-code into an ant-task (extending Task etc) to run from ant. Anthony requested it to be optional (so it could be built without ant dependency), which is implemented also. I changed the source folders of the generator from
> >        * extras/SimpleOrmGenerate/
> >            * simpleorm/..
> >            * org/...
> >        * was moved into extras/SimpleOrmGenerate/src
> >            * simpleorm/..
> >            * org/...
> >        * I added the folder into extras/SimpleOrmGenerate/src-optional
> >            * containing SimpleOrmGenerateTask (ant task wrapper)
> >            * containing property-file used to define ant task-to-class mapping
> >    * To make the ant-bundling optional, I added an Interface to provide property values. By default, system properties are used, but the ant-task can use ant-properties instead.
> >    * I added build.xml, which has tasks to create ant-enabled jar, or jar with ant disabled.
> >    * I added example.xml, showing how to use it as ant task. 
> >    * In the generator code, there were some compilation issues with > java 5.0. Fixed those
> >    * The generator created code with path-separator (:) instead of file separator (/) - at least that happened on my linux -  which does not work well. Fixed that.
> >    * The generator generated somewhat obsolete code, referencing SProperty instead of SFieldString and SFieldFlags. Fixed that. 
> >    * The generator also generated calls to meta.findOrCreate( new Object[] {new Long( _fldId)}); . I have changed that into using a supplied SSessionJdbc connection - I do not know if that makes sense. Since it meant changing the method signature, it will break code based on older versions. Perhaps that should be done in some other fashion?
> >    * TODO: Have not found a replacement for SProperty.SFD_GENERATED_KEY, which supposedly is used on for example AUTO_INCREMENT fields. However, it did not trigger on my tables with AUTO_INCREMENT.
> >    * TODO: I do not really know if the generated code is optimal, perhaps, with new framework, some other methods should be added and some removed ? If so, please let me know (or do the changes yourself).
> >    * TODO: Anthony suggested implementing more rigorous testing framework : generate database from existing test (Employee/Department), then use generator to generate code from that database. I have not implemented that (this was really just a sidetrack on what I was really doing...)
> >
> >I tar:ed the SimpleORMGenerate/ folder into attached file.
> >
> >Regards,
> >Martin Holst Swende
> >
> >
> >--
> >Martin Holst Swende ................. MSC Konsult AB
> >tel: +46(0)70 9519098 ............... Vasagatan 52
> ><mailto:martin.holst_swende <at> msc.se>martin.holst_swende <at> msc.se .......... 111 20 Stockholm
> >
>
> Dr Anthony Berglas, anthony <at> berglas.org       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.
>

--
Martin Holst Swende ................. MSC Konsult AB
tel: +46(0)70 9519098 ............... Vasagatan 52
martin.holst_swende <at> msc.se .......... 111 20 Stockholm

__._,_.___
Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
gould | 9 Dec 2008 21:01
Favicon

Case insensitive string comparison?

Is there any way to do case insensitive string comparison with SQuery without resorting to rawPredicate? If not, it seems that all the drivers would need to know is the LOWER function for their particular dialect.


Thanks,
Carl Gould
Inductive Automation

__._,_.___
Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Anthony & Melissa Berglas | 10 Dec 2008 01:06

Re: Case insensitive string comparison?

No.  To keep it simple, SQuery is only designed to cover the 80% of easy, common cases.  The others can be dealt
with using rawPredicate as you mention.  

SQL 92 functions such as LOWER are generally available on most databases -- even Oracle supports it. 

But real database independence is not that simple.  If your database supports indexing of the LOWER of the
actual value, then you would do it in the query.  If not, then you would store the data LOWERED, and do it in
SQL.  

Real database independence is very hard, and Hibernate et. al. only goes part way at the cost of huge complexity.

Anthony

At 06:01 AM 10/12/2008, you wrote:

>Is there any way to do case insensitive string comparison with SQuery without resorting to rawPredicate?
If not, it seems that all the drivers would need to know is the LOWER function for their particular dialect. 
>
>
>Thanks,
>Carl Gould
>Inductive Automation 
> 

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

Email: berglas <at> spreadsheetdetective.com
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:
    mailto:SimpleORM-digest <at> yahoogroups.com 
    mailto:SimpleORM-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    SimpleORM-unsubscribe <at> yahoogroups.com

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

Anthony Berglas | 10 Dec 2008 05:55

Generator tests now work

If you check out the trunk of simpleorm, run 
  ant demo 
  cd extras\simpleormgenerate
  ant test

you will see the generator run on hsql.

Could do with a bit more work, obviously, but it gives a good head start as is.

Anthony

Dr Anthony Berglas, anthony <at> berglas.org       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:SimpleORM-digest <at> yahoogroups.com 
    mailto:SimpleORM-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    SimpleORM-unsubscribe <at> yahoogroups.com

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

Martin Holst Swende | 11 Dec 2008 11:20
Picon

Auto increment and unique id's

Hi,

The tables I was using were MySQL tables with auto-increment primary 
keys. As I have gathered now from earlier discussions, that does not 
work very well, so I started using the key-generation facilities instead.

* The generator did not notice that my tables had fields that were 
AUTO_INCREMENT. So, the code 'out of the box' did not really work. When 
I created fields (with id's that I set myself) the id's I specified were 
silently ignored. Bug there - should at least give warning at some point.

* Using ses.createWithGeneratedKey(meta) does not work out-of-the box 
either, despite documentation that it defaults to SSELECT_MAX - 
nullpointers were thrown (both mode and params are null). To solve that, 
I added the following to SFieldScalar:

    /**
     * If generator is not already configured,
     * this method initalizes this field to use Default generator mode, 
which is SSELECT_MAX
     *  <at> return the mode
     */

    public SGeneratorMode getGeneratorModeOrDefault()
    {
        if(this.generatorMode == null && this.theGenerator == null)
            this.setGeneratorMode(SGeneratorMode.SSELECT_MAX,  
this.fieldName.concat("_seq_no").toLowerCase());
        return getGeneratorMode();
    }

And modified the SGenerator thus:

   public static  SGenerator theGenerator(SFieldScalar fld) {
        SGenerator gen = (SGenerator)fld.getTheGenerator();
        if (gen == null) {
+            switch (fld.getGeneratorModeOrDefault()) {
-            switch (fld.getGeneratorMode()) {
            case SSELECT_MAX:
                gen = new SGeneratorSelectMax(fld, 
(String)fld.getGeneratorParameter()[0]); break;
            case SSEQUENCE:
                gen = new SGeneratorSequence(fld, 
(String)fld.getGeneratorParameter()[0]); break;
            case SINSERT:
                gen = new SGeneratorInsertIdentity(fld, 
(String)fld.getGeneratorParameter()[0]); break;
            }       
        fld.setTheGenerator(gen);
        }
        return gen;
    }

Should I commit my fix ?

* Remaining question:  my fields are still AUTO_INCREMENT. But it works 
anyway, I guess since auto_increment sets exactly the value that 
SSELECT_MAX expects - they happen to correlate, which I guess is a prime 
candidate for future bugs. What is "The Best" way to handle this: Should 
I remove the AUTO_INCREMENT - property from the fields in MySql and rely 
only on the generator?

-- 
Martin Holst Swende ................. MSC Konsult AB
tel: +46(0)70 9519098 ............... Vasagatan 52
martin.holst_swende <at> msc.se .......... 111 20 Stockholm

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

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:SimpleORM-digest <at> yahoogroups.com 
    mailto:SimpleORM-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    SimpleORM-unsubscribe <at> yahoogroups.com

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


Gmane