Wednesday, August 08, 2007

Improved Model generation in Code Generator

I have improved the Inequality test in the model template, as requested by JimR. This was another case where it worked well for me, only because I followed the convention that primary keys are named ID, and foreign keys are named SingularOfTable_ID. I know that I should really push the Inequality test into the template, but for now, I have corrected it in the DbFieldInfo class.

Labels: ,


Blogger Jim R said...

Unfortunately, I have little-to-no control over my data model. So using naming convention to drive the generator is out of the questiong for me. Some of my systems are being written for a legacy data model and some to a data model being created by my boss (yikes!!) and a contract data modeller. That being said, I have never been fond of driving fucntionality from naming convention, for exactly the same reasons that building business rules into database key values is a bad idea. It will usually come back to bite you.

I beleive that I have one remaining issue to get the generated classes that I need. I am not getting the "HasMany" properties generated. I suspect this is due to my naming scheme not matching yours. I am going to research and attempt to get it to work for me. Of course, I will continue to share what ever I find.

Working with your generator and the code it produces has taught me more about ActiveRecord than the getting started tuitorial on the Castle site did. Thanks.

I hope I am not being too much of a pest.

BTW, I used to live in Oklahoma. I have been gone for several years, but miss it. I do not qualify to be an okie, but both of my children do. :)

August 08, 2007 8:22 PM  
Blogger Roy Tate said...

If you are only missing the [HasMany] attributes, you are in good shape. I did not implement those in my model. I could do so by turning the relations around, and fetching tables that refer to ME, but I haven't done that yet. For now, if you want to maintain flexibility, and be able to re-generate at will, add these attributes to either your BIZ partial, or another partial class. Castle ActiveRecord will see the attribute, and include it in the generated mapping.hbm.xml file. If you want it added to the Entity Model, let me know. By the way, feel free to send me an email through the Google Code project (Roy.L.Tate [at] gmail [dot] com).

If you would submit a SQL script that creates several tables and their relations, I could test my templates against them.

Good Luck, and Happy Hibernating!

August 08, 2007 10:25 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home