Ritchie Warsi

Greenhorn
+ Follow
since Nov 02, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Ritchie Warsi

Hi George thanks for replying.
The common steps like you laid them out to me I understand and already did some matter.

Hibernate configuration, SessionFactory, and a business layer for my Hibernate DAO stuff.
It's like you said, Hibernate is the complex one.

See in my case I use a JDBC realm to log in. As you might know, the logindata is taken out of the database for authentication. Now that would mean I have the username in my session right, cause a succesful login takes the user to it's own page (tested).
Now I want to take the username from the session and use it in a query to get all Customer data that belongs to that username. So my Action should get or set this username and pass it on to the method in my business DAO. No ActionForms thus.

So is there a simple / practical way for this? I don;t have much experience with Java..(yet)
20 years ago
This might be very basic, but I'm still struggling with this.
I got a struts webapp with MySQL and JDBC Realm.

So the user logs in with his customerId and password.
How do I (in my action) get this customerId (login looks it up in UserAccount table) and compare it with customerId from the Customer table.
I use Hibernate for database persistance.

Is something like request.getParameter gonna work, or should I just "set" and "get" customerId?

So my action has to get this customerId that logged in and use it for the following fuction in my Service (Business) class:


List result = null;
Query query =
session.createQuery(
"select Mortgage.mortgageid from Mortgage in class com.test.hibernate.Mortgage where Mortgage.customer=:customerid");
query.setParameter("customerid", customerid);
result = query.list();
return result;



How do I do this and is my approach correct?
20 years ago
Yeah I know it's pretty strange. They said something about the Oracle DB not being connected to the internet by any means, because of other data in it. User priviliges would indeed be the right way, but hell, I'll have to ask again what good reasons they have.

Tnx for your advice and the advice on the approach to take. We'll look into it immediately.
Other advice is always still welcome.

edit: Oracle exp makes a dump right? As far as I know MySQL can't read/import Oracle dumps...or has this changed recently?

edit2: Nevermind, Oracle's CSV export can be read by MySQL it seems.
[ January 06, 2005: Message edited by: Ritchie Warsi ]
The use of 2 databases is not an issue we, as programmers of the webapp, can give advise on. It's something they want to keep like it is.
They've used the oracle database for local purposes, inserting data in it from clients and such and other company related data that is only used locally.
The MySQL DB came along with the implementation of the webapp we have to build and is only necessary to have SOME (not all) info from the Oracle DB, for access with the webapp (only selects mostly).

The data needs to be transfered every day, on schedule or demand is not certain yet. We're talking about 8 tables here, not really large data, but not small either.
The data changes every day, that's why the transfer needs to be on a daily basis.
Hey there,
We are building a Struts webapp for a client that will use a MySQL database.
The webapp will only do getMethods (selects).
The main database were all the info is, is an Oracle DB and so somehow the necessary data will have to go from the Oracle to the MySQL DB.
As the budget is rather limited, I would like to ask you guys with experience what the best way is to do this?
We were thinking of the following:
- Some kind of scheduling, being done via the commandline
- Do a dump of the oracle db to csv or xml and upload it to MySQL
- Some kind of transfer application that will do this locally (as Oracle is NOT connected to the internet and MySQL is)

I hope you understand above points.
Does anyone of you have experience with this? Commercial applications will be our last thing to do, so please advise me other methods.
I was thinking something like, since Tomcat can handle multiple datasources, even the struts webapp can handle multiple datasources, would it be possible to define 2 datasources for the app or Tomcat and somehow do a transfer from time to time?
Allright, I have no other way but to handle it like it was.
My boss makes the datamodel and the database (MySQL) and I let hibernate map the tables and generate the pojo classes.
So it's not up to me unfortunately to think about the structure.

So for instance I got following tables
______________ _____________ ___________
|User_Account| |User_Customer| |Customer |
-------------- ------------- ------------
|Username | |Username | |CustomerID|
|Password | |CustomerID | |Etc etc |
|Role | --------------- ------------
--------------

CustomerID and Username being "foreign" in User_Customer table, Hibernate generates a UserCustomer.java file with id:
So there is another class called UserCustomerKey that consists of

So as you can see, me being a struts n00b, this is very confusing. The Hibernate docs is, in my opinion not really clear on how to actually use this with CRUD operations for instance. (In other words, the doc isn't really n00b friendly i think).

So does anyone know how to do an Insert for instance in this kind of situation? I'm doing all my CRUD related operatotions in a business class and let the action class call those. But yet I have no idea how it should look like (Simple inserts and such I can do).
Allright I still got this same problem. I restarted the whole project, but the problem remains.
The linenumbers in de stacktrace in the first lines all point out (in the end) to either a get or create session method in my HibernateUtil (see my previous post also). So I'm almost beginning to think that that's the problem.
BUT, I use that same HibernateUtil on a different project, developed under the same circumstances and same tools and showing the data list there works fine!

So pleeeeaasssee someone help me out here!
So It's working now?
Maybe a bit offtopic, but can someone post their good working HibernateUtil or SessionFactory here? I'm having trouble with mine (see other topci of mine).
Pascal, the code you posted, is that a custom class or in the HUtil or SessFactory or something?
What does your HibernateUtil look like? I had this problem once begonce i didn't do a commit for the transaction.
I have some other questions regarding Hibernate and Struts. The Hibernate documention has some examples but I cannot find any good examples of use with a struts webapplication, so I hope someone here knows.

I've got 2 tables, say Customer with PK Customer ID and other table UserAccount with composite PK for Username, Password & FK Customer ID.
I have to create a new User Account, filling in a form on a jsp page with 3 fields, username, password & the customer id which the login will belong to.
How do I set up my business and action for this?

I know how to insert into one table (simple insertion), but this is a little bit different.
My businness class should have something like a public void addUserAccount(String username, String password, Customer customerid) thing I reckon?
But what further? Action class etc etc.

If someone can post an example I'd appreciate it!
Hi Mark, by Business Object what file do you mean/should I look for. You see, I don't know all the terms yet
If you mean my CustomerDAO, it's in my webapps/msl2/WEB-INF/classes/*package name directory structure*
I'm building my first Struts/Tiles/Hibernate application and ran into some problems.

I have a Businessclass that has a method for a List, I call on that method straight in my jsp. This same approach did work on another tutorial I was working on, but in my project now it isn't.

Here is the method in CustomerDAO.java:


This is my accOptions.jsp:


And this is my rather long (sorry for that) HibernateUtil.java:


Now when I call on the jsp page the first time I get:


When I refresh that same page i get same exception but different root cause:


I've googled around, found things about classpaths, libraries and such but as far as I can see all is well.
I've got hibernate2.jar AND cglib-full-2.0.1.jar in my WEB-INF/lib.
In my java files I'm referering to the right classes (otherwise Eclipse would warn me about it), so I'm frustrated out of idea's!

Can anyone help me?
O yeah, using JDK 1.5, Tomcat 5.5.4 and Eclipse/MyEclipse.

Another thing. The first rootcause with line 39 is from the throw/catch at wanting to build a SessionFactory and the second one at CustomerDAO:195 is at the List method at trying to get the HibernateUtil.getSession
[ December 22, 2004: Message edited by: Ritchie Warsi ]
Allright, my tomcat error logging isn't configured well, so I'll give you what I get on screen. I'm rather unsure as to what action to call first (getAccountAction or accOptions - the first forwards to the second that calls on a jsp, this is where my data should be - sounds complicated but it's for Tiles).

When calling on getAccountAction i get:


And when calling on accOptions.do i get:


But is my approach correct?

[ December 20, 2004: Message edited by: Ritchie Warsi ]

[ December 20, 2004: Message edited by: Ritchie Warsi ]

[ December 20, 2004: Message edited by: Ritchie Warsi ]

[ December 21, 2004: Message edited by: Jason Menard ]
[ December 21, 2004: Message edited by: Jason Menard ]
20 years ago
I'm a struts newb, so this might be quite easy. All the tutorials I've read or either more complex or they use the jsp itself to generate a list of data.

I want my action class to retrieve my data for me from the db and send in to the jsp page.

So far I've got this (which doesn't work ofcourse):
I wanna use the following method in my CustomerDAO.java:


My getAccountAction.java has:


And my struts-config has the following action mapping:


My simple jsp has:


So obviously I'm doing something wrong or forgetting something. Can anyone point me out what?
20 years ago
Tnx for the answer, but...
I'm rather new at all this, so I have no idea how to check out your suggestions...
I guess my XML parser is dat Xerces thing? or I18n?

Edit, ok is Xerces I'll look into it now, yet I have no idea what exactly to look for

Any more help is appreciated!
[ December 14, 2004: Message edited by: Ritchie Warsi ]
20 years ago