These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Default table mapping
PostPosted: Fri Oct 23, 2009 5:07 am 
Newbie

Joined: Fri Oct 23, 2009 4:52 am
Posts: 1
Hi,

We are migrating an existing application and we want to handle all NHibernate classes / mappings in a uniform way.
In the database, (allmost) all tables have the same base-fields, that is a primary key, a version and a tenantid.
In .NET we created a base class with these fields, all real classes derive from this class, like:

class Entity
{
public int Id;
public int Version;
public int TenantId
}

class Table : Entity
{
// Table specific fields go here
}

We create mapping for all real-classes, but for now we have to specify these Entity-attributes explicitely in every class-mapping, like e.g.

<class name="Table" table="Table">

<id name="Identity" type="int" column="Id">
<generator class="identity"/>
</id>

<version
column="Version"
name="Version"
access="property"
unsaved-value="negative"
/>

<property name="Tenant">
<column name="TenantID" not-null="true" />
</property>

<!-- other properties go here -->

</class>

My question: is it possible to extract the lines marked in blue and import them in every real-table mapping?

Any hints are greatly appreciated

Kind regards,
Martin de Jong
the Netherlands


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.