O/R Broker 1.1 released

Discussions

News: O/R Broker 1.1 released

  1. O/R Broker 1.1 released (47 messages)

    O/R Broker is a JDBC framework, much in the spirit of iBatis, where you roll your own SQL statements.

    Where this framework differs from most other frameworks, is the complete freedom for true OO class design. Most other frameworks have some sort of requirement imposed on the class design, either by requiring extension of a base class, implementation of an interface, or adherence to the JavaBeans component model. O/R Broker does not. You have complete freedom to extend from any base class, and can truly protect your object state by encapsulating your data as you see fit. O/R Broker supports setting data through properties, methods, and even private fields, although the latter can cause issues with SecurityManagers in some environments.

    Simple Example
    <broker name="Test Broker" version="1.0">
    <sql-statement id="getMaxEmployeeId">
    SELECT MAX(EmployeeId) FROM Employee
    </sql-statement>
    </broker>

    InputStream is = getClass().getResourceAsStream("/simple.orbroker.xml");
    Broker broker = new Broker(is, myDataSource);
    Query qry = broker.startQuery();
    try {
    Integer maxId = (Integer) qry.selectOne("getMaxEmployeeId");
    } finally {
    qry.close();
    }
    System.out.println("Max employee id: " + maxId);
    Visit the O/R Broker home page

    Read the User Guide

    Threaded Messages (47)

  2. O/R Broker 1.1 released[ Go to top ]

    Note that the FAQ for this project implis that modern ORM solutions have "object design limitations". This is not the case, transparent ORM solutions only need a no-argument constructor in persistent classes, nothing else.
  3. O/R Broker 1.1 released[ Go to top ]

    This is not the case, transparent ORM solutions only need a no-argument constructor in persistent classes, nothing else.
    First of all, this is not a transparant ORM solution, and doesn't aim to be. Second, requiring a no-arg constructor is often an unacceptable requirement if object state is important (and it should be, if you're dealing with business objects).
  4. O/R Broker 1.1 released[ Go to top ]

    This is not the case, transparent ORM solutions only need a no-argument constructor in persistent classes, nothing else.
    First of all, this is not a transparant ORM solution, and doesn't aim to be. Second, requiring a no-arg constructor is often an unacceptable requirement if object state is important (and it should be, if you're dealing with business objects).
    Oh, and in the JDO case the no-arg constructor may be private! Most JDO implementations will add a protected no-arg constructor if none is provided by the developer.

    Kind regards, Robin.
  5. O/R Broker 1.1 released[ Go to top ]

    Oh, and in the JDO case the no-arg constructor may be private! Most JDO implementations will add a protected no-arg constructor if none is provided by the developer.Kind regards, Robin.
    True, but in certain environments non-public access will make the SecurityManager angry.
  6. O/R Broker 1.1 released[ Go to top ]

    Most JDO implementations will add a protected no-arg constructor if none is provided by the developer.Kind regards, Robin.
    True, but in certain environments non-public access will make the SecurityManager angry.
    This is not an issue in JDO. The constructor is only used from within the class itself (or from within superclasses). I can elaborate if you're interested in the gory details, but suffice it to say that JDO never accesses private or protected fields or methods except from within the persistent class itself.
  7. O/R Broker 1.1 released[ Go to top ]

    This is not an issue in JDO. The constructor is only used from within the class itself (or from within superclasses). I can elaborate if you're interested in the gory details, but suffice it to say that JDO never accesses private or protected fields or methods except from within the persistent class itself.
    Doesn't this depend on the implementation, or is that part of the spec? In any case, JDO needs bytecode enhancement, which is a bit of a hassle, although much more palatable than design restrictions.
  8. O/R Broker 1.1 released[ Go to top ]

    This is not an issue in JDO. The constructor is only used from within the class itself (or from within superclasses). I can elaborate if you're interested in the gory details, but suffice it to say that JDO never accesses private or protected fields or methods except from within the persistent class itself.
    Doesn't this depend on the implementation, or is that part of the spec?
    It's part of the standard bytecode enhancement defined by JDO -- what JDO calls the Binary Compatibility contract. But you're right that an implementation doesn't have to use standard enhancement (or any enhancement at all).
  9. <blockquoteSecond, requiring a no-arg constructor is often an unacceptable requirement if object state is important (and it should be, if you're dealing with business objects).Well, Christian did not say that these solutions require a public no-args constructor. Usually, a private no-arg constructor is sufficient (plus appropriate privileges for the object persistence solution).
  10. transparent ORM solutions only need a no-argument constructor in persistent
    > classes

    And if I don't set the values in the constructor, where are they set? There have to be set methods.

    Whereas, I want to make everything final. I like immutability. It's much safer (threading, accidental change, being used as keys in hashmaps etc etc).
  11. iBatis difference?[ Go to top ]

    From the posted example, I don't see any difference from iBatis. I understand from the FAQ section that a design goal is to be able to populate non-JavaBean style domain classes, but it seems that goal doesn't warrent a completely new framework. Of course, I'm certainly guilty of writing my own framework out of inspiration that I could do it better :)
  12. iBatis difference?[ Go to top ]

    I understand from the FAQ section that a design goal is to be able to populate non-JavaBean style domain classes, but it seems that goal doesn't warrent a completely new framework.
    And this is where I, obviously, disagree. The framework should never dictate your class design. This was what made other open-source frameworks unusable for me.
  13. iBatis difference?[ Go to top ]

    And this is where I, obviously, disagree. The framework should never dictate your class design. This was what made other open-source frameworks unusable for me.
    I guess I'm (genuinely) curious as to why you find that you must design your domain classes without the use of std getter/setters. Is it architecture preference or actual technical need? If it's preference, then so be it. I think you might be in the vast minority, but if it makes you more efficient then more power to you. The only technical need I can see is if you designed your domain classes w/ lots of behavior. I've found that the heavier a domain class gets w/ behavior, the less it lends itself to exposing simple getter/setters. I, personally, think there's a whole slew of other problems that go w/ designing your domain this way, but probably not relevant here.
  14. iBatis difference?[ Go to top ]

    I guess I'm (genuinely) curious as to why you find that you must design your domain classes without the use of std getter/setters. Is it architecture preference or actual technical need? If it's preference, then so be it. I think you might be in the vast minority, but if it makes you more efficient then more power to you.
    Well, I would call it a design need. And it's probably true that I'm in the minority. The JavaBeans component model unfortunately seems to have taken such hold that "good old fashioned" class design is ignored.
    The only technical need I can see is if you designed your domain classes w/ lots of behavior. I've found that the heavier a domain class gets w/ behavior, the less it lends itself to exposing simple getter/setters.

    I would agree :-)
  15. iBatis difference?[ Go to top ]

    Congrats on the release.

    I am confused about this statement...
    O/R Broker breaks with the JavaBeans stranglehold and allows you to map to true OO classes
    Yes, iBATIS supports JavaBeans. However, you can also directly use primitive wrappers (like Integer as in the example above), Maps and even XML or DOM!

    What is it exactly that O/R Broker supports that iBATIS does not?

    Cheers,
    Clinton
  16. iBatis difference?[ Go to top ]

    What is it exactly that O/R Broker supports that iBATIS does not?Cheers,Clinton
    From briefly reading the various docs, the only feature I could find that it had that iBatis did not is the ability to populate a method w/ 'X' number of parameters. So for instance both frameworks could handle:

    setErrorKey(String errorKey)
    setErrorMessage(String errorMessage)

    but only O/R Broker could handle

    setError(String errorKey, String errorMessage)
  17. iBatis difference?[ Go to top ]

    From briefly reading the various docs, the only feature I could find that it had that iBatis did not is the ability to populate a method w/ 'X' number of parameters. So for instance both frameworks could handle:setErrorKey(String errorKey)setErrorMessage(String errorMessage)but only O/R Broker could handlesetError(String errorKey, String errorMessage)
    Yup. Details, details...

    I think there is a consensus that any good Dependency Injection framework should support Constructor Injection AND Setter Injection (Even Aslak has admited it ;)

    So, in the same way, any O/R good framework should support to get a new object instance with setters methods AND specialized constructors, dont you think ?

    Another example : Eric Evans (Domain Driven Design) says that Value Objects are immutable objects (without setters), and to instantiate a value object certainly you will need constructor with all the state as parameters. So JavaBean model does not fit so nicely here.

    Regards
  18. We would like to support setters that create value objects. For example

      SELECT tree_id, latitude, longitude, tree_name FROM t_tree

    should map to

      Tree tree = new Tree(id);
      tree.setName(name);
      tree.setLocation(new Location(latitude, longitude));

    I don't see any support for this in O/R Mapper. (Am I being too demanding?)

    ~Johannes
  19. We would like to support setters that create value objects. For example SELECT tree_id, latitude, longitude, tree_name FROM t_treeshould map to Tree tree = new Tree(id); tree.setName(name); tree.setLocation(new Location(latitude, longitude));I don't see any support for this in O/R Mapper. (Am I being too demanding?)~Johannes
    No, you're not. This isn't yet documented in the User's Guide, but it would look like this (I'm just guessing on the data type of latitude/longitude and tree_id):
    <result-object id="Location" class="package.Location">
    <constructor>
    <argument class="float">
    <column name="latitude"/>
    </argument>
    <argument class="float">
    <column name="longitude"/>
    </argument>
    </constructor>
    </result-object>

    <result-object id="Tree" class="package.Tree">
    <constructor>
    <argument class="int">
    <column name="tree_id"/>
    </argument>
    </constructor>
    <property name="name">
    <column name="tree_name"/>
    </property>
    <property name="location">
    <use-result-object result-object="Location"/>
    </property>
    </result-object>

    <sql-statement id="getTree" result-object="Tree">
    SELECT tree_id, latitude, longitude, tree_name FROM t_tree
    </sql-statement>

    The XML schema for this is in the debug/src folder. That should reveal the possible structure, until I get User's Guide more complete (and the Reference). BTW, the ordering is irrelevant.
  20. constructors with args[ Go to top ]

    I was skeptical looking at this, but looking quickly at the docs, I really like the support for constructors with arguments. This lets you not include setters for immutable fields, which I think is nice.
  21. iBatis difference?[ Go to top ]

    Congrats on the release.

    Thanks Clinton.
    What is it exactly that O/R Broker supports that iBATIS does not?
    Mapping to constructors (for potentially immutable objects), mapping to methods with multiple arguments, mapping to private fields (although not always recommended). Support for FreeMarker, Velocity and maybe other template engines later.
    It's been a while since I've looked at iBatis, so I don't know if it supports the following features as well (please correct me if I'm mistaken):
    * Support for dynamic mapping to class hierarchies (http://orbroker.sourceforge.net/documentation/user-guide.shtml#inheritance)
    * Support for timezones for correct mapping of DATE/TIME/TIMESTAMP fields

    Thanks,
    Nils
  22. iBatis difference?[ Go to top ]

    Just a silly question: if you found iBatis lacking some features, why didn't you ask its developers community for implementing them? If you had convinced them, you could implemented it as new iBatis feature. That's how open source works.

    More users means more testing, more developers attraction etc. Your users cannot enjoy iBatis stability and features, iBatis users cannot enjoy your new features that differentiate it. If you could find way with Clinton for merge, both communities could join and create yet better library :-)
  23. iBatis difference?[ Go to top ]

    Just a silly question: if you found iBatis lacking some features, why didn't you ask its developers community for implementing them?
    I did have a couple of emails go back and forth between Clinton and me in January this year when I was just checking iBatis out. I was my feeling that there was a difference in opinion on the philosophy of mapping. Clinton didn't consider even an ID to be immutable. I completely respect his opinion, but the more I thought about it, there was just too many things I would do differently. So I did.
  24. O/R or R/O[ Go to top ]

    Where this framework differs from most other frameworks, is the complete freedom for true OO class design
    What do do mean by "true OO class design". I read the user guide and the only reference to OO I found was inheritance. What about other OO concepts such as polymorphism, abstraction, interface/implementation decoupling,...
    I may be wrong, but the feeling I had when reading the doc was that O/R Broker is more a R/O mapping tool than a O/R mapping tool.
  25. O/R or R/O[ Go to top ]

    What do do mean by "true OO class design". I read the user guide and the only reference to OO I found was inheritance.
    And the obvious one: encapsulation.
    What about other OO concepts such as polymorphism, abstraction, interface/implementation decoupling,...
    This is all things you can do without the tool preventing you.
    I may be wrong, but the feeling I had when reading the doc was that O/R Broker is more a R/O mapping tool than a O/R mapping tool.
    Sure. Trust me, it's difficult finding a name combination that hasn't already been taken. If you object to the accuracy of the name, I won't disagree.
  26. O/R or R/O[ Go to top ]

    I do not see any problems in constructors, properties or data structures too.

     broker.newQuery( "findMyThings", new MyMappingStrategy() );
    What do do mean by "true OO class design". I read the user guide and the only reference to OO I found was inheritance.
    And the obvious one: encapsulation.
    What about other OO concepts such as polymorphism, abstraction, interface/implementation decoupling,...
    This is all things you can do without the tool preventing you.
    I may be wrong, but the feeling I had when reading the doc was that O/R Broker is more a R/O mapping tool than a O/R mapping tool.
    Sure. Trust me, it's difficult finding a name combination that hasn't already been taken. If you object to the accuracy of the name, I won't disagree.
  27. O/R or R/O[ Go to top ]

    I do not see any problems in constructors, properties or data structures too.
    Ok?
    broker.newQuery( "findMyThings", new MyMappingStrategy() );

    Are you talking about multiple mapping strategies, decided at runtime? That's an interesting concept, although I'm not sure I've ever needed that. Do you have a use case?
  28. O/R or R/O[ Go to top ]

    Yes, I use it for streaming :
    broker.newQuery( "findMyThings", new MyMappingStrategy(outputStream) );

    "MappingStrategy" is a very trivial interface:

    Object transform( Resultset rs )
  29. O/R or R/O[ Go to top ]

    Yes, I use it for streaming :broker.newQuery( "findMyThings", new MyMappingStrategy(outputStream) );"MappingStrategy" is a very trivial interface:Object transform( Resultset rs )
    Sounds more like a task for XStream or something like it. Unless you want to stream directly from ResultSet to stream? In any case that would be way outside the scope of O/R Broker.
  30. O/R or R/O[ Go to top ]

    Yes, I use it for streaming :broker.newQuery( "findMyThings", new MyMappingStrategy(outputStream) );"MappingStrategy" is a very trivial interface:Object transform( Resultset rs )
    Sounds more like a task for XStream or something like it. Unless you want to stream directly from ResultSet to stream? In any case that would be way outside the scope of O/R Broker.
    Yes, you do not need to implement this "strategy" in framework, user can delegate for some XStream himself. See commons DbUtils, it looks like Spring doe's the same too. More usefull thing must be a code generator, editor as pluggin for IDE (with SQL completion, coloring, query executor, result viewer ) monitoring tool.
  31. Congrats![ Go to top ]

    After reading the user guide (and seeing the posts here) I reckon there's enough differentiation in this to head off the "not another orm tool" brigade. There are some nice features involving object creation and parameter setting. I could see the big advantage of this being where you need to persist an existing model but can't/don't want to alter the source.

    I would like to see performance results under heavy load though. The descriptors at times almost look like object scripting. (How) Is this optimised / cached?

    Keep up the good work!

    Kit
  32. what’s in a name[ Go to top ]

    Congratulation from me too!

    Is there any tool or CodeSmith templates to give you a head start?

    Clinton, you should not be grumpy. Nils clearly states that he was inspired by iBATIS! And he have no C# version yet.

    Considering that it is over 40 ORM products on the market it is time for some opposition. But what name should it have? "Non-Orm data mappers? XML data mappers? or just SQL-mappers?

    Regards
    Rolf Tollerud
  33. what’s in a name[ Go to top ]

    Since it is a mapper, and at one side you have objects and at the other a relational database, I suggest we name it a Object/Relational Mapper. :) KISS.

    Regards,
    Henrique Steckelberg
  34. what’s in a name[ Go to top ]

    Is there any tool or CodeSmith templates to give you a head start?
    Not yet. I'm working on a GUI, but it's low priority, so it may be a while.
    I would suggest a good schema-sensitive XML editor, it makes a huge difference.
  35. what’s in a name[ Go to top ]

    Clinton, you should not be grumpy. Nils clearly states that he was inspired by iBATIS!
    I'm hardly grumpy! I was merely confused as to what the differentiating factors were. Certainly constructor based result mappings would be simple to add to iBATIS (and indeed they will be).

    Just as O/R Broker was inspired by iBATIS, so will iBATIS be inspired by O/R Broker (...and Mr. Persister, and....).

    We'll be sure to keep up with new trends and developments as they appear.

    Cheers,
    Clinton
  36. Clinton,

    "We'll be sure to keep up with new trends and developments as they appear"
    I am sure you will!

    "Just as O/R Broker was inspired by iBATIS, so will iBATIS be inspired by O/R Broker (...and Mr. Persister, and....)."
    Just so, but iBATIS was the first! (Credit where credits due :)

    All I want now is nice Tool. It should be like a two pass compiler.

    1) The Tool helps you by generating the SQL from the database and embed it in nice XML (SQL-map) files.

    2) Then you have to fine tune/add/delete the generated SQL by hand, marking the ones that you predestine as domain objects.

    3) Then the Tool runs the second pass, generating the entity classes, CRUD code and the resultsets XML from the SQL-map files!

    Regards
    Rolf Tollerud
  37. One of good features I like in this kind of tools is a SQL validation, I just execute this stuff using "EXPLAIN" prefix, It gives me query plan too.
    Next I can generate DAO at runtime using dynamic proxy and example code becomes:

    interface EmployeeManager {

      public static final EmployeeManager INSTANCE =
         (EmployeeManager)Helper.implement(EmployeeManager.class);
      
     int getMaxEmployeeId(int min, int max);

    }

    EmployeeManager.INSATNCE.getMaxEmployeeId();


    This stuff can generate code for statistics collection and trace without any code, but related to code.
    It is possible to plugg custom "mappers" and strategies too, is not it ?
  38. que?[ Go to top ]

    I guess nobody understands what you are saying Jouzas, I don't! :)
  39. que ?[ Go to top ]

    +1
  40. que?[ Go to top ]

    Yes, probably I need to sleep more.
  41. que?[ Go to top ]

    I am talking about this garbage:

    InputStream is = getClass().getResourceAsStream("/simple.orbroker.xml");
    Broker broker = new Broker(is, myDataSource);
    Query qry = broker.startQuery();
    try {
    Integer maxId = (Integer) qry.selectOne("getMaxEmployeeId");
    } finally {
    qry.close();
    }

    I think it must be better to replace it with single typesafe method call (aka DAO)

    int value = dao.getMaxEmployeeId();

    It must be trivial to generate this code using XML definition, I do it at runtime using cglib. As I understand this kind of code is always hidden in DAO, is not it ? why do you need to write this garbage manualy ?
  42. I think Nils wants you to write your own little wrapper..
  43. It becomes not so little with all cool and usefull stuff.

    int getMaxEmployeeId(double min, double max){

     final String signature = "int getMaxEmployeeId(double,double)";
     final Object [] params = new Object[]{ new Double(min), new Double(max) };

     securityCheck( signature, params, currentUser() );
     
     long time = currentTime();
     
     Broker broker = currentBroker();

     traceSQL(this.getClassName(),
       signature, broker.getSQLString("getMaxEmployeeId"), params
      
    );


     Query qry = broker.startQuery();
    try {
     Integer maxId = (Integer) qry.selectOne("getMaxEmployeeId",
                 new Object[]{ new Double(min), new Double(max) }
            );
     return maxId.intValue();

    } finally {
      qry.close();
      statisicsCollector.hit(this.getClassName(),
         signature,time
       );
    }

    }
    It is boring to write, is not it ? You need nothing more than method declaration to generate it.

    The most coll stuff is statistics viewer, it can be javadoc style html generated at runtime, it can relate statistics to packages,classes,methods with hit count,execution time, cache hit/miss , sort stuff by some rate, view query plan.

    The most usefull stuff is query validation, tool knows all queries defined in metadata and it can execute SQL with fake parameters on startup or it can be invoked by ant.

    In short this kind of frameworks have future, they are more friendly than drivers for OO database.
  44. not so little[ Go to top ]

    We really are extravagant aren't we? Both security Check, sql tracer and statistic collector! I guess you don't deny yourself anything in real life either? Still why not? Only the best is good enough! :)

    In my opinion (that stands on two legs, logic deduction and simple observations), your code represent the culmination of a free and unself-conscious art no longer practiced in the crass world of today!

    "In short this kind of frameworks have future, they are more friendly than drivers for OO database."

    true, true.

    Regards
    Rolf Tollerud
    (Have a nice Saturday-evening and do nothing that I wouldn't do..)
  45. not so little[ Go to top ]

    Do you need to make this method remote ? You do not need nothing more this XML file to generate WS or CORBA stuff too. Do you need OOP model ? Ok, connect to database with tool and view it, it can be viewed as objects,tables,tries,DDL or XML schema, but API is DAO (services) structs (static) or maps (dynamic) anyway.
  46. Graph Paging[ Go to top ]

    I would be interested in your thoughts on this article: http://www.theserverside.com/blogs/showblog.tss?id=GraphPaging
  47. Graph Paging[ Go to top ]

    I would be interested in your thoughts on this article: http://www.theserverside.com/blogs/showblog.tss?id=GraphPaging
    Yes, I remember reading that. It's some interesting thoughts, but not much substance. I seems more aimed at products like EJB, JDO, and Hibernate, which actually tries to hide the backend. O/R Broker (and similar frameworks) requires you to know about, and write to, the RDBMS backend. It's a different perspective, and something depends on your personal preference.
  48. O/R Broker v2.0 has been released.