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.  [ 5 posts ] 
Author Message
 Post subject: Problems with hbm2net
PostPosted: Thu May 10, 2007 6:36 pm 
Newbie

Joined: Tue Mar 27, 2007 4:45 pm
Posts: 9
Hello everybody,

for generating the domain objects I am using the hbm2net tool. Unfortunately I have some difficulties concerning Nullable types and proxies:
Proxies: The properties are not marked with virtual so I have to do an extra search & replace after each code generation.
Nullables: Having the following property
Code:
<property name="Deadline" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />

the generated property has also the type "Nullables.NHibernate.NullableDateTimeType" instead of "Nullables.NullableDateTime".

Are there some specific parameters I have to pass or are these two features (Nullables, proxies) not yet supported by hbm2net?


Top
 Profile  
 
 Post subject: Problems with hbm2net
PostPosted: Wed Jun 06, 2007 8:17 am 
Newbie

Joined: Wed Jun 06, 2007 7:51 am
Posts: 2
Hi rainerh,

I'm new to nhibernate too, but I fixed this two issues by changing the hbm2net application.
I wonder why no one else has these problems?! And why no one has answered to this question!

I changed file FieldProperty.cs line 132 to
..
Code:
return getScope("scope-get", "public virtual"); }


and
Code:
if (typeof(IType).IsAssignableFrom(clazz))
{
   IType ut = (IType)SupportClass.CreateNewInstance(clazz);
   log.Debug("Resolved type: " + type + " to " + ut.ReturnedClass.Name);
   string t = clazzToName(ut.ReturnedClass);
   return t;
}


in file ClassMapping.cs Line 584 of the NHibernate.Tool.hbm2net.Console-2.0 project.
I recompiled the app and this worked fine for me, but this is just a temp. solution. I'm also interested in finding out to do it right.

Ciao

Martin


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 4:26 am 
Newbie

Joined: Fri Jun 29, 2007 4:18 am
Posts: 1
Hello!
Does anybody know, how to generate with virtual modifier?
I think, change source of hbm2net is not right method...


Top
 Profile  
 
 Post subject: Problems with hbm2net
PostPosted: Fri Jun 29, 2007 4:51 am 
Newbie

Joined: Wed Jun 06, 2007 7:51 am
Posts: 2
Hi

you can specify inside each id, property and set a meta tag like

Code:
<meta attribute="scope-get">public virtual</meta>


But it looks very ugly (my opinion) in the xml and for me it looks like this is a bug in hbm2net because nHibernate needs this virtual declaration.

This and some other problems leads to, that I don't use hbm2net any more and code my classes on my own.
So far I didn't found any tool that generate class and hbm.xml files in that way I need it.
Especially if the database makes us of xref tables with additional columns or derived classes (tables).

But if someone has a good tip.. I still loking for good tools that make live easier ;-)

Ciao

Martin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 05, 2007 11:28 am 
Newbie

Joined: Wed Sep 05, 2007 10:32 am
Posts: 1
Hello!
If you want each property of the generated class to have "public virtual" modifier, you can use another renderer of hbm2net: BasicRenderer. The default renderer is VelocityRenderer.
You have to provide a config xml file (e.g. hbm2net.config.xml) to change the renderer:
Code:
<?xml version="1.0" encoding="utf-8"?>
<codegen>
<generate renderer="NHibernate.Tool.hbm2net.BasicRenderer"/>
</codegen>

Call hbm2net on command line by:
Code:
NHibernate.Tool.hbm2net.Console.exe --config=hbm2net.config.xml MyClass.hbm.xml

Hope it helps.


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

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.