Menu

Enum Handling, Reserved words & Java 8 Date/Time API

Help
2014-04-09
2014-04-09
  • Dennis Fischer

    Dennis Fischer - 2014-04-09

    Hello,

    I've found Sormula via stackoverflow and it's the first out of the box working ORM. I guess you didn't receive my email (I've used the contact form on the sormula website, which somehow didn't seem to work - or I just failed :D).

    I have a pretty complex object graph that fits perfectly well into a relational database. During the initial setup I've found some minor problems.

    Enum's seem to be "not" working out of the box. I expected Sormula to use the ordinal or name of the enum value. Looks like it's handled like a new table. I'm not sure if this can be solved efficiently, because enum parent class in java is working a bit strange, but like to hear your feedback on this. Is a TypeTranslator enough - maybe shipped by default?

    One of my tables used a reserved word "Order". Maybe I shouldn't use "Order", but I simply couldn't find any better matching name. Sormula generates SQL and doesn't escape fields resulting in an exception. Escaping all fields could be a solution.

    Lastly Java 8 Date/Time API support would be cool. I've added a TypeTranslator myself now - which was amazingly simple.

    Final question: I've got a one sided many to many relation including tables A, B and A_B. I've taken a look at the examples and declared my field with: @OneToManyCascade(name = "A_B")
    I didn't get what the option "readOnly" means. If readOnly is set: I store a new Object of type A, which has contains a List \<B> field. The relation is saved in A_B + any changes to the B objects are saved in the corresponding B table.

    Regards,

    Dennis Fischer

     

    Last edit: Dennis Fischer 2014-04-09
  • Jeff Miller

    Jeff Miller - 2014-04-09

    It is always good to hear from people that are using Sormula.

    You could try the contact again. I have received email from others who use the contact page. I have a anti-spam built in that may have filtered yours out.

    Sormula should be able to handle a graph of unlimited depth and complexity. The examples and tests use up to 3 levels.

    I have not tried to store enum in table. enum's could be annotated as Transient if you don't want to map them to a table. A TypeTranslator may help with enum. If you could send an example, I could experiment.

    You can escape the table name in SQL with double quotes. Tell Sormula to do this by using Row annotation. There are several examples of these in the org.sormula.examples package.
    @Row(tableName="\"order\"")

    I have read about the Java 8 features. I plan to create new TypeTranslators for the new date/time classes.

    If you would like to send an example of one to many, I could experiment with it. The readOnly attribute of the cascade annotations means that the child objects are only selected but never inserted, updated, or deleted.

     

Log in to post a comment.