How to extend the <property>'s tags attribute

Posts   
 
    
sjjoshi
User
Posts: 6
Joined: 09-Jul-2010
# Posted on: 12-Jul-2010 07:30:46   

Hi,

Let's say we have a table "Customers" with columns as CustomerID - (int) PK FullName - varchar(100) Mandatory, LastName - varchar(100) Mandatory, EmailID - varchar(100) Mandatory, Country - varchar(100) Mandatory, PhoneNo - varchar(100) Not Mandatory, MobileNo - varchar(100) Not Mandatory.

However, when I use LLBLGen, the generated hbm.xml file contains as below.

<class name="Customer" table="[dbo].[Customer]" optimistic-lock="version" > <id name="CustomerID" column="CustomerID" access="field.camelcase-underscore" > <generator class="assigned"/> </id> <property name="FullName" column="FullName" access="field.camelcase-underscore"/> <property name="LastName" column="LastName" access="field.camelcase-underscore"/> <property name="EmailID" column="EmailID" access="field.camelcase-underscore"/> <property name="Country" column="Country" access="field.camelcase-underscore"/> <property name="PhoneNo" column="PhoneNo" access="field.camelcase-underscore"/> <property name="MobileNo" column="MobileNo" access="field.camelcase-underscore"/>

Now, I would like to have few more attributes to the <property> with more info like, length, null/not-null, etc. Sample below.

<property name="FullName" column="FullName" length="100" not-null="true" access="field.camelcase-underscore"/> <property name="LastName" column="LastName" length="100" not-null="true" access="field.camelcase-underscore"/> <property name="EmailID" column="EmailID" length="100" not-null="true" access="field.camelcase-underscore"/> <property name="Country" column="Country" length="100" not-null="true" access="field.camelcase-underscore"/> <property name="PhoneNo" column="PhoneNo" length="100" not-null="false" access="field.camelcase-underscore"/> <property name="MobileNo" column="MobileNo" length="100" not-null="false" access="field.camelcase-underscore"/>

So, is there any settings or do we need to do this manually?

Cheers.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 12-Jul-2010 10:54:18   

sjjoshi wrote:

Hi,

Let's say we have a table "Customers" with columns as CustomerID - (int) PK FullName - varchar(100) Mandatory, LastName - varchar(100) Mandatory, EmailID - varchar(100) Mandatory, Country - varchar(100) Mandatory, PhoneNo - varchar(100) Not Mandatory, MobileNo - varchar(100) Not Mandatory.

However, when I use LLBLGen, the generated hbm.xml file contains as below.

<class name="Customer" table="[dbo].[Customer]" optimistic-lock="version" > <id name="CustomerID" column="CustomerID" access="field.camelcase-underscore" > <generator class="assigned"/> </id> <property name="FullName" column="FullName" access="field.camelcase-underscore"/> <property name="LastName" column="LastName" access="field.camelcase-underscore"/> <property name="EmailID" column="EmailID" access="field.camelcase-underscore"/> <property name="Country" column="Country" access="field.camelcase-underscore"/> <property name="PhoneNo" column="PhoneNo" access="field.camelcase-underscore"/> <property name="MobileNo" column="MobileNo" access="field.camelcase-underscore"/>

Now, I would like to have few more attributes to the <property> with more info like, length, null/not-null, etc. Sample below.

<property name="FullName" column="FullName" length="100" not-null="true" access="field.camelcase-underscore"/> <property name="LastName" column="LastName" length="100" not-null="true" access="field.camelcase-underscore"/> <property name="EmailID" column="EmailID" length="100" not-null="true" access="field.camelcase-underscore"/> <property name="Country" column="Country" length="100" not-null="true" access="field.camelcase-underscore"/> <property name="PhoneNo" column="PhoneNo" length="100" not-null="false" access="field.camelcase-underscore"/> <property name="MobileNo" column="MobileNo" length="100" not-null="false" access="field.camelcase-underscore"/>

So, is there any settings or do we need to do this manually? Cheers.

Column is only necessary if the Column name is different from the property name. It otherwise gets the same value as the 'name' attribute. not-null is not an attribute of 'property', so I don't know why you'd want to have that added. Similar to 'length': http://nhforge.org/doc/nh/en/index.html#mapping-declaration-property

Is this for generating your own db schema from nhibernate? Why not export the ddl sql from llblgen pro instead?

Frans Bouma | Lead developer LLBLGen Pro
sjjoshi
User
Posts: 6
Joined: 09-Jul-2010
# Posted on: 14-Jul-2010 06:09:29   

Thanks a lot.

As am new to LLBL, just was trying to figure out whether I can implement any validation to the columns.

DDL SQL is very nice and I liked the feature.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 14-Jul-2010 06:23:36   

You can write your own templates for validating stuff. You can access such info in the template system. For more info read the SDK manual.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 14-Jul-2010 10:32:37   

Additionally, NHibernate offers in the NHcontrib library a validation system based on interceptors, the preferred way to extend NHibernate. Did you look into that as well?

Frans Bouma | Lead developer LLBLGen Pro
kDanel
User
Posts: 5
Joined: 14-Jan-2011
# Posted on: 18-Jan-2011 13:49:39   

Hi guys,

Is it possible to add generated attribute to property for columns that have default database values? <property generated="insert" ....

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 18-Jan-2011 21:43:13   

It's not an option that the templates provide at the moment. It is always something you could look to add yourself.

Why do you need them ?

(PS - please start a new thread rather than re-opening an old one for new questions)

Matt