-->
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.  [ 2 posts ] 
Author Message
 Post subject: Dynamically produce Business Objects for NHibernate (runtime
PostPosted: Sat May 05, 2007 3:49 pm 
Newbie

Joined: Sat May 05, 2007 3:38 pm
Posts: 2
Okei, to start off; I'm new to Hibernate and I have no idea if it can solve our problem. So if I ask questions that are stupid (and they might be!) please don't bite my head off... ;)

Now, we have a database intensive application with a lot of old code. Most of the code is > 4 years old and a lot of the database interaction stuff is > 6 years old. We're in the process of swapping out our db code and that's what has lead me to look at NHibernate.

Today we build most of our Sql statements dynamically, based on metadata. So we have a bunch of tables that we do CRUDs against, without knowning at compile time what those tables are called or what columns they have (only in metadata, not in code). The way we produce these Sqls is done in a very manual way and is VERY limited in functionality, performance, security and code maintainability... :(

So, my questions is; would it be possible to tweak NHibernate to be able to accommodate our needs? To sum it all up; we need to produce CRUD sql statements against tables that are not defined at compile time. :)

Any help, ideas, tips or otherwise constructive feedback would be most helpful.

Cheers!

_________________
- Jarle -


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 07, 2007 6:46 am 
Newbie

Joined: Sat May 05, 2007 3:38 pm
Posts: 2
Okei, since my first post wasn't really good or specific I'm trying to add some more details.

Assume that we have a bunch of tables that look like this:
C_Company (Company [PK], Description, Disabled)
C_Equipment (Equipment [PK], Description, Disabled)

Now, in our framework (today) it's possible to define new tables like this without changing the source code. All that is required is a new row in another table like this:
X_Define_Codes (CodeNumber [PK], TableName, PrimaryKey, DescriptionColumn, DisabledColumn, ...) Values (1, 'C_Company', 'Description', 'Disabled', ...)

(Neither of the tables are actual names nor are they complete, but I'm hoping that it's enough to illustrate how the framework is built up)

So, what we really want to do, by using NHibernate or another (our own?) ORM library would be;
Code:
ICodeTable code = Enityfactory.Create(1); // 1 == C_Company, according to X_Define_Codes
code.GetDescription(1); // Returns the description for Company code 1

ICodetable newCode = EntityFactory.CreateNew();
newCode.PrimaryKey = 2;
newCode.Description = "Foo Inc.";
newCode.Disabled = "";
newCode.Save();

ICodetableCollection codes = EntityFactory.CreateCollection(2);
codes.GetAll();
foreach (ICodeTable code in codes)
    code.Description....;


Does any of this make sense? Have anybody done anything like this with NHibernate or any other ORM lib.?

_________________
- Jarle -


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.