-->
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.  [ 42 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: Mon Jun 06, 2005 3:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
What ? session.connection() is plain JDBC ... nothing special about that ,)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 3:21 am 
Newbie

Joined: Mon Jun 06, 2005 1:53 am
Posts: 6
Location: shanghai / cn
max wrote:
What ? session.connection() is plain JDBC ... nothing special about that ,)


So you know how to use that? Can you help me with a small example? Help is appreciated. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 3:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sorry, but that i'm not going to help with - waaay to much documentation in the world about JDBC and how to use it for me to show basic examples.

Use google and search for JDBC tutorial!

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 10:16 am 
Newbie

Joined: Mon Jun 06, 2005 1:53 am
Posts: 6
Location: shanghai / cn
And there is really no other way in Hibernate 2 then using JDBC, when I want to do a simple UPDATE + update restrictions?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 10:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No, UPDATE-by-query is a Hibernate3 feature.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 10:20 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This is getting a bit ridiculous


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 10:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - and with good reason since bulk updates does not fit very well with ORM that needs to do cascades and other stuff to make life easier for you.

But in Hibernate3 (and EJB3) we now have support for bulk updates because it can come in handy some times.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: finally someone has a solution ...
PostPosted: Mon Jun 06, 2005 11:29 am 
Newbie

Joined: Mon Jun 06, 2005 11:16 am
Posts: 2
Location: Austria
christian wrote:
This is getting a bit ridiculous


I really had to register, cause I can't stand the ignorance of the moderators in this forum anymore.

asaingal and leethacker, I've got some homebrewn sample code for you:

Code:
Session session = HibernateSessionFactory.currentSession();
List l = session.find("from Kunde as k where ... whatever ... ;-) "); // the query
      
for (ListIterator iter = l.listIterator(); iter.hasNext();) {
Object[] o = (Object[])iter.next();
Kunde k = (Kunde)o[0];
k.setName("stuff to put in db field"); // write into database field
session.flush();
}


this will easily work with hibernate 2. enjoy & tell me if it worked ... :-)

I think if someone has posted this before, this would have saved much time and annoyance of some ppl ...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 11:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Hi Robertpeloscheck,

Glad for you to answer - It would be great if more users did that! Then you would not see me trying to answer basic questions ;)

but again:
The first question was someone who actually didn't know how to do a simple update (so I would rather point him to the docs than explain the
basics)

The second question was explicitly about bulk update which resulted in a basic question on how to use JDBC...

Your answer is what is in the very first chapter of the reference doc or any tutorial out there!

But I very much welcome people who wants to explain this stuff every day to every question that need it - and will continue doing that since people will just come back and ask simple stuff here instead of reading the basics of the existing documentation (i'm serious here!)

Peace!
/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 1:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
OK, enough.

(1) If you can't abide by the rules of the forum, don't post here
(2) If you can't obey directions given you by the "moderators" of this forum, don't post here
(3) If you want to insult us, don't post here
(4) If you can't figure our Hibernate without a degree of handholding that we do NOT provide in the forum, either
(a) buy a support contract or go to a training, (and so do something to support the development of Hibernate) OR
(b) go start your own Hibernate forum, or post at JavaRanch OR
(c) don't use Hibernate

The so-called "moderators" of this forum are the people who created and develop Hibernate. Providing free support to users is NOT part of our job descriptions and our employer would be just as happy if we did not do it at all. Likewise, the opportunity to deal with demanding, whiny or lazy people was NOT the reason I started this project, and I would be extremely happy if I did not have to do it at all.

Most of the posts in this forum are looked over, however briefly, by *someone* from the Hibernate team (we get all posts as email). But support we provide comes at the expense of time we could be spending making Hibernate better for everyone. Noise in the forum makes the forum harder to use for non-selfish people - people who DO read documentation - ie. the people we WANT to help out, and makes it harder for us to track real problems as our email inboxes fill up with nonsense.

Now, in the entire 3 year history of Hibernate, we've had to ban probably less than 15 people (something I most certainly do not get a kick out of). In this past week - one of the worst weeks for a long time - I had to ban 3, and came close to banning a couple more. Now, this is a tiny drop in the bucket compared to the 200 000 people who downloaded Hibernate3 in the past two months, the vast mass of who are apparently able to read documentation and show initiative in solving the problems they are paid as professional software developers to solve. But I will not let the forum now degenerate as it has occasionally degenerated in the past, so be aware that I am now on a hair trigger as far as bannings go for the rest of the month.

Don't be lazy.
Don't insult people who give you free things.
Don't try to argue.

There are plenty of places in the Internet where you can be lazy, insulting and argumentative. Just not here.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 4:10 pm 
Newbie

Joined: Mon Jun 06, 2005 1:53 am
Posts: 6
Location: shanghai / cn
Thanx for ya help robertpeloschek! Your code solved my problem within minutes. Hope you stay here in this forum and help other people as well. :-)


Top
 Profile  
 
 Post subject: Re: Problem with save
PostPosted: Thu Feb 09, 2012 11:56 pm 
Newbie

Joined: Thu Feb 02, 2012 11:28 pm
Posts: 13
Location: shenzhen china
where is your transaction?
Never commit,never save

Code:
try{
        Session session2 = HibernateSessionFactory.currentSession();
        Transaction tx = session2.beginTransaction();
        session2.createQuery("update Kunde as k set k.onlinepwd = '" + text_onlinepasswort.getText() +  "' where k.kartennr = " + 8);
        tx.commit();
    }catch(Exception e){
        e.printStackTrace();
    }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 42 posts ]  Go to page Previous  1, 2, 3

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.