Composite objects

From: Derek Rendall (cayenn..sure.com)
Date: Mon Nov 08 2004 - 23:02:00 EST

  • Next message: Michal Kozlowski: "RE: Getting info across databases..."

    Hi

    In our existing code base we have two cases where we have objects within
    objects.

    The first is basicaly the classic Address within Party where we have an
    object that wraps several attributes of the domain object in order to
    provide certain standardised functionality. Other examples include cases
    where we have several related attributes dealing with taxation etc. In this
    case we do not need to create these objects outside of the context of their
    parent.

    The other case involves a class we created a class that wraps a BigDecimal.
    In our current data layer we translate attributes that are instances of this
    object to/from a BigDecimal in the database. We have a lot of complex code
    that uses this wrapping class, and I want to change things as little as
    possible. In this case, we do need to be able to create this object outside
    of its parent and assign it to an attribute on the parent.

    Is there a way to do either (similar to Hibernates User Objects/Types?),
    particularly the second case? If not, is such functionality planned anytime
    soon? If the answer is still no, what would be the best approach to try and
    implement such behaviour?

    Also, while Im writing an email to the list: I noticed that BigDecimals with
    a scale can get their scaled values set when pushing to the database, but
    the object does not reflect this. For example, if I have a scale of 2 for a
    BigDecimal and I set the attribute to "0.155" then "0.15" is persisted, but
    the object still states "0.155". DB2 throws an exception if the scale is
    wrong, so this behaviour stops the exception happening (which I tend to
    agree with from a practical point of view), but I want the object and
    database data to match after saving. I had thought of changing the java
    template so that BigDecimals are checked for scale in the set method. Is
    there a better alternative? Could this be thought of as a bug, and I need to
    raise a Jira issue?

    Thanks

    Derek



    This archive was generated by hypermail 2.0.0 : Mon Nov 08 2004 - 23:02:05 EST