The ObjectMapper .NET Project

Official blog of the AdFactum ObjectMapper .NET

Archive for August, 2007

Using Oracle DECODE function to evaluate if an aggregated object does exists

Posted by Gerhard Stephan on 23rd August 2007

When you are doing a flat load of an object, the aggregated child objects won’t be loaded and the property in your entity class is set to NULL. At the first glance you can’t say whether the aggregated child object is not loaded or the aggregated child object does not exist in database.

To change this, we have to grab into our bag of tricks. Using the DECODE Function of Oracle we can determinate if a aggregated child object does exists or not.

public class Invitee : ValueObject   
{
        Contact _invitedContact;
        bool    _hasInvitedContact;

        /// <summary>

        /// The aggregated Contact

        /// </summary>

        [PropertyName("CONTACT")]

        public Contact InvitedContact

        {

            get { return _invitedContact; }

            set { _invitedContact = value; }

        }

             

        /// <summary>

        /// Using the Select Function the decide if an

        /// aggregated object does exists in database.

        /// </summary>

        [SelectFunction("DECODE(#SR#INVITEE.CONTACT,NULL,0,1)")]

        public bool HasInvitedContact

        {

            get { return _hasInvitedContact; }

            set { _hasInvitedContact = value; }

        }

 

 

 

 

As you can see the Select Function is using the Oracle DECODE function to determinate whether the aggregated contact does exists or not. The result of the SelectFunction will be mapped to the boolean value "HasInvitedContact". Using this hint you don’t have to explicit load the aggregated child object from database in order to say whether it does exists or not.

Remark: The placeholder #SR# is a constant used by the AdFactum ObjectMapper .NET. The constant will be replaced with the oracle shema when generating the SQL.

 

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Posted in Hint | No Comments »

New Project-Team License Model

Posted by Gerhard Stephan on 17th August 2007

Today we start offering our new project team license model.

If you’re working in a development team you won’t need to buy every single developer a license for the AdFactum ObjectMapper .NET. Since today it’s sufficient to buy one team license. It doesn’t matter how many members are within your team. That reduces the costs of the software license for the AdFactum ObjectMapper .NET significant.

Remember: The AdFactum ObjectMapper .NET is not free at all. It’s only free if you’re publishing your product under the GPL License. If not, you have to register yourself at our registration website and buy a valid license. When buying our products, you will receive a printed product certificate as a proof of your ownership.

Hope to welcome you as a new registered customer.

Best regards
Gerhard Stephan

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Posted in Miscellaneous | No Comments »

New Release – AdFactum ObjectMapper .NET 1.81.1917.0

Posted by Gerhard Stephan on 17th August 2007

This release solves a bug that occured sometimes when saving aggregated objects which are bound by the [GeneralLink] attribute. The ObjectMapper .NET crashed with a NullReferenceException. That bug has now been fixed.

Wish you a nice weekend
Cheers

Gerhard

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Posted in Releases | No Comments »

How to get the primary key of an aggregated entity when doing a flat load of the parent.

Posted by Gerhard Stephan on 16th August 2007

Today I will show you a way to retrieve the ID of an aggregated object, even when doing a flat load of the parent.

Normally when doing a flat load of an object, the aggregated child objects will stay untouched and the properties will return null. This is cool, as long you don’t need them. But out of my experience there are not only these two cases – to load the aggregated objects, or not to load. Often you don’t need the content of the aggregated object, but you need the primary key of them. For such cases you have to insert a second property which will be filled by the attribute [SelectFunction] of the AdFactum ObjectMapper .NET.

    public class Invitee : ValueObject

    {

        Contact _invitedContact;

        /// <summary>

        /// The aggregated Contact

        /// </summary>

        [PropertyName("CONTACT")]

        public Contact InvitedContact

        {

            get { return _invitedContact; }

            set { _invitedContact = value; }

        }

             

        /// <summary>

        /// Using the Select Function the ID of the aggregated

        /// object will also be mapped, even if the object

        /// is only flat loaded.

        /// </summary>

        [SelectFunction("CONTACT")]

        public Guid InvitedContactId

        {

            get { return _invitedContactId; }

            set { _invitedContactId = value; }

        }

 

 

 

 

 

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Posted in HowTo | No Comments »