Gilbert johnson

Ranch Hand
+ Follow
since Jul 10, 2005
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gilbert johnson

And also this user is able to drop the whole database.

So he should not be able to drop tables or database.

Hello fellow ranchers

I need some information on how to grant/revoke privileges on mysql database.

Basically I want to create a user and grant him select,insert and update permissions on the database. This is the user with which I'm connecting from my web app to perform operations.

So I connect as root and create the database discountweb - then I'm using the following command

GRANT SELECT, INSERT, UPDATE ON discountweb.* TO 'discountweb'@'localhost' IDENTIFIED BY 'test123' WITH GRANT OPTION;

This works fine - but this user (discountweb) also has the option to drop any table.

Can anyone let me know - how to revoke the drop privilege for this user.

I'm kind of stuck here - and my mind is drawing complete blank - it seems like a pretty simple issue - but for some reason I'm not getting it.

I have 2 tables - Product and ProductAttributes. In the product pojo- I have a OneToMany relationship with productAttributes as shown below:

Now when I need to display - the product and its values - I would simply load the product and pass it to the JSP page where I'll display the attributes as shown below:

Each product has its own set of attributes. Now I need to create a form where the user can edit the product information like attributes etc.

So I have a product form which contains a set of product attributes. Now how do I display these attribute values in the jsp page so that they are editable.

Basically I'm getting confused on the syntax for path. If my command name is product, what do I put for the path value for attributes:
Thankyou Mark - That link seems very informative. I will go through that. Thanks a lot for sharing that information. Appreciate it.
Hello everyone,

I'm a bit lost and need some guidance. I've just inherited this web application written in spring/hibernate and I'm trying to get myself familiar with this technology.

One of the first things I need to do is to keep the user logged in for like 2 weeks or till he explicitly logs out. The application runs on Tomcat - and I think by default - if there is no activity - the user is being logged out in 20 mins.

I know to keep the user logged in for 2 weeks or so - we have to use cookies and set the max age or something. Are there any articles that talk about how this is done.

In this application, I dont even see any LoginController. All the pages that require login are marked in web.xml - When any of those pages are requested - the login.jsp page shows up and if I look in the form action - it says j_security_check.

So I'm not even sure, which controller I should be using to set cookies and stuff. If anyone can guide me a little, I will really appreciate it.

Hi Anil,
Do you have experience in Spring and Hibernate technologies.
14 years ago
Hi Madhavi,
Do you have experience in working on Spring and Hibernate.
14 years ago
I actually do agree with both of you.
Its actually more of a hack to get it to work.

So does that mean - Hibernate does not support many to many if the join table has extra columns
Pedro - Yes that was something I did change

Cameron - Thankyou for the detailed response you provided. But as Gregg mentioned, I have an extra column in the association table. Like in your case, the join table has only two columns that refer to the two entities. But in my case the join table has an extra column apart from the two foreign keys.

Gregg - Yes you are right. The price is based on the combination of product and retailer.

While searching I came accross this site - and was able to implement this solution. Hope this helps someone else.

I appreciate all the help everyone provided.
thankyou very much
Hey Greg,
Thanks for your detailed response. The approach you mentioned would work fine if the joining table did not have any extra columns. Like in your case Product_ProductOffer table consist of only 2 cols, product_id and product_offer_id.

But in my case the association table consists of an extra column (price) apart from the two foreign keys.

So from what I've read, I need to create a seperate class RetailerProduct and do two oneToMany associations. But I'm not able to get that to work.

I am using Spring,Hibernate Annotations based approach.
I have two entities. Product and Retailer which have a many to many association.
A product can belong to MANY retailers
A retailer can have MANY products

So I have a join table retailer_product which has the following columns
productId - referring to Product Table (id)
retailerId - referring to Retailer Table (id)

So how do I map these associations. This is what I have so far that doesnt work.
@Table(name = "product")
public class Product {
@OneToMany(mappedBy = "product")
private Set<ProductRetailers> productRetailers = new HashSet<ProductRetailers>(0);
@Table(name = "retailer")
public class Retailer {
@OneToMany(mappedBy = "retailer")
private Set<ProductRetailers> productRetailers = new HashSet<ProductRetailers>(0);
@Table(name = "retailer_product")
public class RetailerProduct {
@JoinColumn(name = "retailerId", referencedColumnName = "id")
private Retailer retailer;

@JoinColumn(name = "productId", referencedColumnName = "id")
private Product product;
Obviously there is some problem here and it doesnt work.
What I want to be able to do is retrieve all retailers that sell a particular product
and find all products that are sold by a particular retailer.

Can anyone help me with this. Will really appreciate it.
Thanks a lot in advance
First of all - want to thank everyone who contributes in this forum. It has helped me immensely so many times when I have been stuck.

Right now I am on my quest to learn hibernate and have already asked questions here before.

I have two tables - Group and Product which have a bi-directional many-to-many relationship. A group can have many products and a product can belong to many groups.

So I introduced a join table "Group_Product" - now this table has an extra column userID. So one of the members of this forum suggested two approaches - and I went with the approach of using two one-to-many associations. Everything is working fine.

Now I want to retrieve all products that belong to a particular Group.
In my Java Code - using groupId, I'm loading the Group object.
From my Group object - I'm getting a set of GroupProduct.
Now GroupProduct has objects Group and Product and userId as members.

Now in my java code, I have:

The code is printing userID and productID but throws an exception while printing productName.

I know thats because, its only querying Group and Group_Product table. Its not linking Group_Product table with Product table.

What am I missing. Really appreciate your responses.

Here are my hbm.xml files



[ March 26, 2008: Message edited by: Gilbert johnson ]
Hello Stevi,

Thankyou for your detailed response. I did try the way you suggested. Although I dont see any error - but nothing is being inserted into GroupProduct table.
I added what you provided in Product.hbm.xml

Should I add this in Group.hbm.xml

I'm new to hibernate and am stuck on this issue for sometime now and would really appreciate some help.

I have two tables - GROUP and PRODUCT
Its a many to many association between them.
A group can have many products
A product can belong to many groups

So I have a join table - GROUP_PRODUCT which has groupID and productID.
But it also has an extra column userID

This is what I have added in my Group.hbm.xml file for this purpose

This is what I have product.hbm.xml for this purpose

Now when I try to create a group and add a product to this group, I see the following sql statements followed by this error:

If you look at the 2nd sql,the insert statement does not even include the extra field userID

I know I'm missing something very basic here. So if you could point me in the right direction - I would greatly appreciate it.


I have these chinese characters stored in the database in NCR format
eg: &# 25705;&# 26681;&# 22823;&# 36890; -->Something like this (I've purposely added the space after &#).

When you view these characters in the browser - they appear as chinese.

So I need to write these characters to an excel file (CSV), and in excel file they would not appear as Chinese. So I played around a bit, I found a function online that converts a string in NCR format to unicode. So I used that function and used the fileoutputstream to write these characters and it WORKED.

This was in JDK - Now when I compile the same code in JDK 1.6 -> it does not that any methods are deprecated - but the chinese characters dont show up - instead some junk characters are displayed in the excel file.

What am I missing. Will appreciate any of your insights.
15 years ago