Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/07/2011, 10:20
vdebronik
 
Fecha de Ingreso: julio-2011
Mensajes: 9
Antigüedad: 13 años, 4 meses
Puntos: 0
Problema struts2 hibernate OneToMany

Hola!

Tengo una base de datos con dos tablas, las cuales están relacionadas por uno de sus campos y la relación es de tipo OneToMany. Estoy usando hibernate con anotaciones y primero probé a mapear una sola tabla.

EL fichero hibernate.cfg.xml para una sola tabla es
<?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="connection.driver_class">com.mysql.jdbc.Driv er</property>
<property name="connection.url">jdbc:mysql://localhost:3306/usuarios</property>
<property name="connection.username">veronica</property>
<property name="connection.password">vero2108</property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.No CacheProvider</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping class="tables.User"/>
</session-factory>
</hibernate-configuration>

Para mapear la segunda tabla, creo la clase Java exactamente igual que para la primera tabla y añado:

<mapping class="tables.ComputeEngine" />

más @OneToMany, @ManyToOne y @JoinColumn en las clases.

Obtengo la siguiente excepción:

java.lang.NullPointerException
actions.LoginAction.execute(LoginAction.java:34)
sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.opensymphony.xwork2.DefaultActionInvocation.in vokeAction(DefaultActionInvocation.java:452)
com.opensymphony.xwork2.DefaultActionInvocation.in vokeActionOnly(DefaultActionInvocation.java:291)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:254)
com.opensymphony.xwork2.interceptor.DefaultWorkflo wInterceptor.doIntercept(DefaultWorkflowIntercepto r.java:176)
com.opensymphony.xwork2.interceptor.MethodFilterIn terceptor.intercept(MethodFilterInterceptor.java:9 8)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.validator.ValidationInterc eptor.doIntercept(ValidationInterceptor.java:263)
org.apache.struts2.interceptor.validation.Annotati onValidationInterceptor.doIntercept(AnnotationVali dationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterIn terceptor.intercept(MethodFilterInterceptor.java:9 8)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ConversionErro rInterceptor.intercept(ConversionErrorInterceptor. java:133)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInte rceptor.doIntercept(ParametersInterceptor.java:207 )
com.opensymphony.xwork2.interceptor.MethodFilterIn terceptor.intercept(MethodFilterInterceptor.java:9 8)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInte rceptor.doIntercept(ParametersInterceptor.java:207 )
com.opensymphony.xwork2.interceptor.MethodFilterIn terceptor.intercept(MethodFilterInterceptor.java:9 8)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.StaticParamete rsInterceptor.intercept(StaticParametersIntercepto r.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.MultiselectIntercep tor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.CheckboxInterceptor .intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.FileUploadIntercept or.intercept(FileUploadInterceptor.java:243)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ModelDrivenInt erceptor.intercept(ModelDrivenInterceptor.java:100 )
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ScopedModelDri venInterceptor.intercept(ScopedModelDrivenIntercep tor.java:141)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.debugging.Debugging Interceptor.intercept(DebuggingInterceptor.java:26 7)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ChainingInterc eptor.intercept(ChainingInterceptor.java:142)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.PrepareInterce ptor.doIntercept(PrepareInterceptor.java:166)
com.opensymphony.xwork2.interceptor.MethodFilterIn terceptor.intercept(MethodFilterInterceptor.java:9 8)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.I18nIntercepto r.intercept(I18nInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.ServletConfigInterc eptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.AliasIntercept or.intercept(AliasInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ExceptionMappi ngInterceptor.intercept(ExceptionMappingIntercepto r.java:187)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:248)
org.apache.struts2.impl.StrutsActionProxy.execute( StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAc tion(Dispatcher.java:485)
org.apache.struts2.dispatcher.ng.ExecuteOperations .executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrep areAndExecuteFilter.doFilter(StrutsPrepareAndExecu teFilter.java:91)


¿Alguna idea?