-->
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 1, 2, 3  Next
Author Message
 Post subject: Problem with save
PostPosted: Fri Jun 03, 2005 2:11 pm 
Beginner
Beginner

Joined: Tue May 31, 2005 5:36 pm
Posts: 21
Hibernate version: 2

I have the following code

Code:
Session session2 = HibernateSessionFactory.currentSession();
                  session2.saveOrUpdate("Kunde as k set k.onlinepwd = '" + text_onlinepasswort.getText() +  "' where k.kartennr = " + text_kartennr.getText());


and get the following error

Code:
java.lang.RuntimeException: Unknown entity class: java.lang.String
   at ticketline.WebAccount$1.widgetSelected(WebAccount.java:195)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2908)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2541)
   at ticketline.MainApp1.open(MainApp1.java:736)
   at ticketline.MainApp1.runMain(MainApp1.java:103)
   at ticketline.Login1$2.widgetSelected(Login1.java:139)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2908)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2541)
   at ticketline.Login1.open(Login1.java:216)
   at ticketline.Login1.main(Login1.java:61)


What do I do wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 04, 2005 1:15 am 
Beginner
Beginner

Joined: Tue May 31, 2005 5:36 pm
Posts: 21
Nobody got an idea?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 12:17 am 
Regular
Regular

Joined: Tue Mar 01, 2005 2:35 pm
Posts: 60
Umm... I don't know why there have been 30+ views of this thing and no replies. Anyway, SaveOrUpdate takes an object that you have created or made changes to that you would like add to or update in the database. Use Session.createQuery().


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 4:39 am 
Beginner
Beginner

Joined: Tue May 31, 2005 5:36 pm
Posts: 21
pkulak wrote:
Umm... I don't know why there have been 30+ views of this thing and no replies. Anyway, SaveOrUpdate takes an object that you have created or made changes to that you would like add to or update in the database. Use Session.createQuery().


Hey! Thanx for the answer. Unfortunately it seems that I do something wrong, cause nothing is stored in the database when I use the following code:

Code:
                  Session session2 = HibernateSessionFactory.currentSession();
                  session2.createQuery("update Kunde as k set k.onlinepwd = '" + text_onlinepasswort.getText() +  "' where k.kartennr = " + 8);


Doing the same thing in the Database Manager works perfect for me:

Code:
update kunde set kunde.onlinepwd = 'rookie' where kunde.kartennr = 8;


So what do I do wrong in my java code? I have no idea, coz there is no error message. All I can see, that nothing is stored...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 9:47 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Did u call

session.flush()

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 10:14 am 
Beginner
Beginner

Joined: Tue May 31, 2005 5:36 pm
Posts: 21
ramnath wrote:
Did u call

session.flush()
No, but now I did, and again nothing happened. :-(


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 10:18 am 
Beginner
Beginner

Joined: Tue May 31, 2005 5:36 pm
Posts: 21
ramnath wrote:
Did u call

session.flush()


No, but now I did, and again nothing happened. :-(


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 11:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
are you completely sure you have read the documentation ? ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 1:13 pm 
Beginner
Beginner

Joined: Tue May 31, 2005 5:36 pm
Posts: 21
max wrote:
are you completely sure you have read the documentation ? ;)


Sure, but the API allone often does not help. What I need are examples. And didn't find them anywhere.

Please, help a n00b. :-))))


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 1:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
go to hibernate.org and click documentation - should keep you busy for a while ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 1:18 pm 
Beginner
Beginner

Joined: Tue May 31, 2005 5:36 pm
Posts: 21
max wrote:
go to hibernate.org and click documentation - should keep you busy for a while ;)


c'mon max. i promise i will - but please tell me whats wrong with my code. i need it to be completed till tomorrow, or i'll get in real trouble. :-(


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 1:21 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Man, just read the stupid documentation and copy/paste. Nobody here is going to help you out on a Sunday writing trivial code. We don't know whats wrong with your stuff.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 1:25 pm 
Beginner
Beginner

Joined: Tue May 31, 2005 5:36 pm
Posts: 21
christian wrote:
Man, just read the stupid documentation and copy/paste. Nobody here is going to help you out on a Sunday writing trivial code. We don't know whats wrong with your stuff.


And how do you know that simple copy/paste will help then? Great forum here btw. ... Especially the friendly people answering here. Man, why do you hang round in this forum on Sunday, when you don't wanna help people ...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 1:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
It has already been told to you .....saveOrUpdate doesn't take a string it takes a persistent object.

You apparently isn't using hibernate as it should be....go read the docs.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 1:31 pm 
Beginner
Beginner

Joined: Tue May 31, 2005 5:36 pm
Posts: 21
max wrote:
It has already been told to you .....saveOrUpdate doesn't take a string it takes a persistent object.

You apparently isn't using hibernate as it should be....go read the docs.
/max


I know, and if you look down a few posts, you will see that I don't use it anymore. Now I try it with createQuery which takes strings.

Code:
Session session2 = HibernateSessionFactory.currentSession();
                  session2.createQuery("update Kunde as k set k.onlinepwd = '" + text_onlinepasswort.getText() +  "' where k.kartennr = " + 8);
session2.flush();


And with this code I have no error message, but somehow nothing is stored into the database. And coz there is no error message, I have no idea what's wrong.

Maybe you hibernate insiders know without any error message what I forgot to do or what I've done wrong ...


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 1, 2, 3  Next

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.