rodrigo bengoechea

Greenhorn
+ Follow
since Nov 15, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by rodrigo bengoechea

Santosh I've solved the problem it was a mistake in the hbm's mappings. Many thanks for all your help! Now my laptop doesn't have internet connection since I'm at work but if you want I'll post the changes in the mappings when I get home.

Thanks again!!!

Rodrigo.
Hi! I've used the System.out and the parameter's values are correct... could be something else?
I think so, how can I display the parameter's value? I'm pretty lost with this...

Thanks!
Hi everyone!, I'm developing my first application using hibernate and I'm having an error while I'm mapping a many to many relation. I've tried several times to fix it but I haven't been able to do it so I decided to ask you.

Basically the relation is this: A Group is made of many Users and a User can be part of many Groups.

Please if anyone could tell me something it would be very useful since I have no experience with this framework. I know this post could be pretty long but I'm desperate to fix this.

Thanks in advance to everyone!
Regards.

Rodrigo

Here I give you the User class:



Here's the User hbm:



Here's the group class:



Here's the Group hbm:



Here's the code where I'm relating the user with the group:



Here's the save group method:


And Finally the stacktrace:


Hi!!! Happy new year for everyone!!!
I'm developing a web application in which a user can create and join groups to share files and messages. In the welcome page of any user it's displayed the list of groups the user is member.
The problem I'm trying to solve is that, once the list is displayed, if the user clicks on the link of any group the application must redirect to the main page of that group. The javascript recieve the index of the list of groups. But I must be doing something wrong because the javascript is never excecuted...

Here I post the code when the list is diplayed in the jsp and the call to the javascript:



And here I post the javascript function code:


Thanks everyone in advance!!
Regards.

Rodrigo.
Thanks aswin java!!! I solved the problem instantly!!!
Hi everyone!, I'm devoloping my first application using hibernate and I'm getting an error when I'm doing a query to my database. I was looking for solutions the last 3 days and I can't figure out where's the mistake, so I decided to consult you.

Basically, I'm developing a web application where users can create group and adminstrate them. To map this relation I've created a class named user that has a set of groups to administrate and a class named group that has a reference to it's administrator. When I'm trying to find out if a group with a certain name exists and exception it's thrown. Can anybody help me please?

Here's the code:

The hibernate config:


The hbm:


The User class:


The Group class:


The method of the GroupDAO class where I'm getting the exception:


And finally the error:


Anything you could tell me will be very helpful!
Thanks everybody in advance!

Merry Christmas!

Rodrigo.
Hi everyone! I'm developing my first web application using hibernate and as everybody would know hibernate is not friendly at all for begginers. I'm stuck with this error and I can't figure out where's my mistake, so if someone has any idea it would be very helpful.

Basically, what I'm trying to do is to know if there's a group named as the parameter:



This is the error that I'm getting:
19:44:46,968 INFO [STDOUT] Hibernate:
select
group0_.id as id2_,
group0_.name as name2_,
group0_.category as category2_,
group0_.creation_date as creation4_2_,
group0_.admin_id as admin5_2_
from

Group group0_ where
group0_.name=?
19:44:47,062 INFO [STDOUT] 19:44:47,062 WARN [JDBCExceptionReporter] SQL Error: 1064, SQLState: 42000
19:44:47,078 INFO [STDOUT] 19:44:47,078 ERROR [JDBCExceptionReporter] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Group group0_ where group0_.name='MRC'' at line 1
19:45:43,031 INFO [STDOUT] 19:45:43,031 WARN [RequestProcessor] Unhandled Exception thrown: class org.hibernate.exception.SQLGrammarException
19:45:43,031 ERROR [[action]] Servlet.service() para servlet action lanz� excepci�n
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Group group0_ where group0_.name='MRC'' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1026)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1761)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1912)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at dao.GroupDAOImpl.groupExists(GroupDAOImpl.java:25)
at services.ServiceImpl.groupExists(ServiceImpl.java:52)
at action.createGroup.CreateGroupAction.execute(CreateGroupAction.java:48)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Unknown Source)

Here's the Group Class:


And here the hbm:


Please any suggestion will help me a lot!!

Thanks everyone in advance!
Hi everyone! I�m newbe using Hibernate and I�m trying to figure out where�s my mistake mapping a one-to-may relation. I�ve been the last hours trying to solve it but I couldn�t, so I decided to ask you. Please any suggestion will help me a lot!!

I explain you the bussines logic here:
every user has one or more passwords, and a password can be removed from a user.

I know that my post it�s a quite long but I tried to provide you everything you should need...

So here�s the User class:


Here the Password class



Here the User mapping xml:


Here�s the hibernate config:


Here where I�m creating the user:


And finally here�s the stack trace:


Thanks in advance for your help!!!
Regards!!!
Hi!, I`ve just start to develop using hibernate and I'm dealing with a one-to-many mapping using a List. Everything goes fine until the application tries to save the objects into the data base. I've been trying to figure out where's my mistake but I couldn't. If someone has any idea it would be great.

Above I post my two classes, the stacktrace and the hibernate config files.

Here's my class user:

package beans;

import java.util.Date;
import java.util.ArrayList;
import java.util.List;

public class User {

private long id;
private String name;
private String sirName;
private String user;
private List passwords;
private String authentication;
private Date registrationDate;
private String email;

public User(){
passwords = new ArrayList();
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getSirName() {
return sirName;
}

public void setSirName(String sirname) {
this.sirName = sirname;
}

public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}

public String getAuthentication() {
return authentication;
}

public void setAuthentication(String authentication) {
this.authentication = authentication;
}

public Date getRegistrationDate() {
return registrationDate;
}

public void setRegistrationDate(Date registrationDate) {
this.registrationDate = registrationDate;
}

public List getPasswords() {
return passwords;
}

public void setPasswords(List passwords) {
this.passwords = passwords;
}

public void setPassword(String password){
passwords.add(password);
}

public boolean hasPassword(String password){
return passwords.contains(password);
}
}

Here's the Password class

package beans;

public class Password {

private String value;
private long id;

/*public Password(String value){
this.value = value;
}*/

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

}

The User.hbm file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="beans.Password" table="Password">
<id name="id" type="long" column="id" unsaved-value="0">
<generator class="increment"/>
</id>
<property name="value" type="string" column="value"/>
</class>

<class name="beans.User" table="User">
<id name="id" type="long" column="id" unsaved-value="0">
<generator class="increment"/>
</id>
<list name="passwords" cascade="all">
<key column="user_id"/>
<index column="id"/>
<one-to-many class="beans.Password"/>
</list>
<property name="name" type="string" column="name"/>
<property name="sirName" type="string" column="sir_name"/>
<property name="user" type="string" column="user"/>
<property name="authentication" type="string" column="authentication"/>
<property name="email" type="string" column="email"/>
<property name="registrationDate" type="date" column="registration_date"/>
</class>
</hibernate-mapping>

Here the hibernate config file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">10</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">admin</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<!-- <property name="hibernate.c3p0.max_size">3</property>-->
<!--<property name="hibernate.c3p0.min_size">1</property>-->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/gruposweb</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

<property name="show_sql">true</property>
<property name="format_sql">true</property>

<mapping resource="beans/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>

And finally the stacktrace

8:58,655 INFO [STDOUT] 19:38:58,655 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: beans.Password, getter method of property: id
19:38:58,655 ERROR [STDERR] org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of beans.Password.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:176)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3257)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:2983)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:460)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:84)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:502)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:494)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:134)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:290)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:185)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:160)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:410)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:299)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:114)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:530)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:518)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)
at dao.UserDAOImpl.registerUser(UserDAOImpl.java:37)
at services.ServiceImpl.registerUser(ServiceImpl.java:15)
at action.register.RegisterAction.execute(RegisterAction.java:48)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)

Please if anyone has some idea please share it with me.

Regards!!!

Rodrigo.