-->
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: Execute statement and some business logic
PostPosted: Thu Jan 10, 2008 4:51 am 
Newbie

Joined: Thu Jan 10, 2008 3:50 am
Posts: 4
I apologize for having posted this initially to the wrong group. It's a .NET issue.



Hi,

I have a couple of problems and I've been banging my head against the wall. I need to do some simple operations that I think any business application can have...nothing out of the ordinary.

When I create a new customer, I have a custom method to obtain a numerator (it's not the ID and I don't want to use generator). Is it not possible to just execute a statement? Soemthing like "update x set y=y+1"? Forget even returning the result. Can't I just execute a direct SQL statement? I just don't see myself having to create a numerator class, the class mapping and do things like:

Numerator numerator = new Numerator();
int value = numerator.GetNextNumerator();
session.Update(numerator);

where GetNextNumerator gets a ID and then increments it. It's just an overkill.

My other problem is with transactions. If I have a sequence generator in the ID, TransactionScope fails with cannot open data connection. I have to use Begin/End Transaction.

Also, even if I rollback my transaction, my generator in Firebird is still updated.

I'm really close to throwing in the towel with NH and I don't want to :(


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 12, 2008 9:44 am 
Contributor
Contributor

Joined: Tue May 30, 2006 1:25 am
Posts: 29
You can create your own ID generator implementing IIdentifierGenerator.
Any way, before do that take a look to all generators NH have because I think that you don't need to create another one (your generator sound like TableGenerator).

In order to your "transaction problem" I think you are wrong. In general the ID generator work out of transaction-scope (I mean when you are working with real POID outside business).
http://www.crionics.com/products/openso ... bjects.pdf

Bye.

P.S. Take a look to our others forums too
http://www.hibernate.org/365.html

_________________
Fabio Maulo.


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.