kwame Iwegbue

Ranch Hand
+ Follow
since Sep 02, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by kwame Iwegbue

Sorry, dumb question. Its supposed to say:

17 years ago
JSP
I need some help.

I have this code:



this displays: Nov 2, 2007 1:30:21 PM

Unfortunately it is 1 hr off! The correct time should be Nov 2, 2007 2:30:21 PM

if I change the timeZone attribute to "EDT", it's: Nov 2, 2007 6:30:51 PM

Any thoughts?
[ November 02, 2007: Message edited by: kwame Iwegbue ]
17 years ago
JSP
I'm new to Spring, but i've read a lot of documentation, but still can't figure this one out. need help from anyone with experience with @Transactional using <tx:annotation-driven>

I have this:




"sessionFactory" is correctly defined.
Then my service class (Which uses Hibernate 3.1) has this:





then this is from the stack trace:





Any ideas? is this a problem with hibernate?
I have a new remote mysql database, and I would like to run an Ant target from my local machine to build a hibernate database schema on the remote site.
my jdbc settings are something like:



but I keep getting this error:

[hibernatetool] Error #1: java.sql.SQLException: Connections could not be acquired from the underlying database!

I know the database exists, and that I have the right un and pw. this tools works fine when building the schema on localhost on my machine.
any ideas please?
I agree with you about detached objects, but my feeling was that with Open Session in View Pattern (which is what I'm using) , the persistence-context (unit of work) is wrapped by the request-responce cycle (in a servlet filter) so you application objects never get detached on their own, unless I close the persistence context prematurely. So I'm not sure this is the problem.

The Code for my VisitDAO is



the actual method is from GenericHibernateDAO, which is



The rest of the methods in the DAO are simply database queries.
detached huh?, Well I'm using the Open session in View pattern, i.e the whole request-response cycle is wrapped in a Hibernate Session. So I guess it could be detached after the delete method exits or something. But why would that be a problem. Do I need to re-attach it after the loop or what?
Post sample of your Person class. I think Hibernate will use all the properties to make the composite key. Therefore they should be not null, unless you use idbag.
Thanks.
All other properties of the containing Entity (Visit) are managed correctly by hibernate, including other Collections, which are Collections of Entities mapped by one-to-many association. Even this particular troublesome Collection of Value type objects (Diagnoses) is managed correctly in every way, except when it comes to delete. According to everything I've read so far, removing a Value type object from a Collection should cause it to be deleted as well.
visitDAO is a data access object that loads the Entity, Visit from the database.

Has no one out there using Hibernate, run into this type of situation that I describe in this question, or is it still unclear what I'm asking, or is it just a dumb question. Can some hibernate guru please help me with this!!
Here's whats going on:



So Visit is an Entity (has database identity) and Diagnosis is a Value type (has no database identity).

I can manage a Visit object with



However, this won't work with Diagnosis. So if I want to delete a DIagnosis object, which is in a Set that is mapped to a Visit object, I do this:



So this works, and removes the Diagnosis from the Collection, however, when Visit is loaded again, the "deleted" Diagnosis is still present in the Collection!
[ August 23, 2007: Message edited by: kwame Iwegbue ]
Can someone please help with this problem. Its been over a week, and I still can't figure it out. Let me rephrase the question:
Is there a special way of handling Collections of objects in Hibernate, when those objects do not have a database identity. I know that Objects with identiy, mapped in a Collection with *-to-many, are managed by the Hibernate session and can be removed by session.remove() etc; but how about regular objects?

When I try to remove them like from the Collection, they are reloaded from the database when the Collection is again accessed. Please help!!!
[ August 22, 2007: Message edited by: kwame Iwegbue ]
I think I've found the solution.
Someone had a similar issue on this forum, and they are using
Ostermiller utils

I'm going to give it a shot.
[ August 22, 2007: Message edited by: kwame Iwegbue ]
17 years ago
I'd like some help with parsing a csv file to put the info into a database. I have some crude way of doing this using StringTokenizer and then persisting the fragments one by one. I was wondering if there is a more elegant way to do this, since my technique might lead to corrupted data.

Thanks.
17 years ago
Thanks Shailesh,

The thing is, the Diagnoses object is not an entity, but a Collection of value types without a database identity. They are embedded in another class, which is an Entity. When I remove one of the objects in the List, it is deleted from the List as expected, but when the List is called from the JSP, it is again loaded from the database. How can I overcome this? I can't call session.delete() because I dont want to delete the Entity.
[ August 16, 2007: Message edited by: kwame Iwegbue ]
In that case you can initialize the List with a call like myList.size() or something like that. That would usually load the Collection from the database. Or, you can change the class mapping to make it eager loaded. With Annotations, you would write something like this: