-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: "node to traverse cannot be null"
PostPosted: Thu Jun 16, 2011 11:15 am 
Newbie

Joined: Sun Jun 12, 2011 1:43 pm
Posts: 10
I checked the internet and i can't find a solution to the problem. Would someone please help me with this one.

DeleteDocumentAction.java
******************
Code:
public class DeleteDocumentAction extends ActionSupport {

   private static final long serialVersionUID = 2640141927469006062L;
   private String project_id; //currently has no use//wanted to re-populate setup-project.jsp
   private String document_id;
   
   public String execute(){
      Session s = HibernateUtil.getSessionFactory().openSession();
//      s.createQuery("delete from Document d where d.id="+document_id).executeUpdate();
//      s.close();
//      s = HibernateUtil.getSessionFactory().openSession();
      List<String> content_id = (List<String>)s.createQuery("c.id from Content c where c.document="+document_id).list();//<<ERROR
//      s.createQuery("delete from Content c where c.document="+document_id).executeUpdate();
      
//      String c_id;
//      for(int i=0;!content_id.isEmpty();){
//         c_id = (String)content_id.get(i);
//         System.out.println("DeleteDocument>Got Content id>"+c_id);
//         s.createQuery("delete from Translation t where t.expression="+c_id);
//         
//      }
      
      s.close();
      return SUCCESS;
   }


Content.java
***********
Code:
@Entity
@Table (name = "DOC_CONTENT")
public class Content {
   private Long id;
   private Document document;
   private int position;
   private String expression;
   private List<Translation> translations;
   private int translationLanguage;
   
   public void setDocument(Document doc) {
      this.document = doc;
   }
   
   @ManyToOne(cascade=CascadeType.ALL)
   @JoinColumn(name="document_fk")
   public Document getDocument() {
      return document;
   }
   
   public void setExpression(String expression) {
      this.expression = expression;
   }

   @Column(name = "expression")
   public String getExpression() {
      return expression;
   }
   
   public void setTranslations(List<Translation> translation) {
      this.translations = translation;
   }
   
   @OneToMany(targetEntity=net.translators.logic.documents.Translation.class,
         cascade=CascadeType.ALL,mappedBy="expression", fetch=FetchType.EAGER)
   public List<Translation> getTranslations() {
      if(translations == null)
         translations = new ArrayList<Translation>();
      return this.translations;
   }
   
   public void addTranslation(Translation translation){
      getTranslations().add(translation);
   }
   public void setTranslationLanguage(int translationLanguage) {
      this.translationLanguage = translationLanguage;
   }
   
   @Column(name = "translation_language")
   public int getTranslationLanguage() {
      return translationLanguage;
   }

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

   @Id
   @GeneratedValue
   public Long getId() {
      return id;
   }

   public void setPosition(int position) {
      this.position = position;
   }

   @GeneratedValue(strategy=GenerationType.SEQUENCE)
   @Column(name="position")
   public int getPosition() {
      return position;
   }
   
}



Document.java
***************
Code:
@Entity
@Table(name="DOCUMENTS")
public class Document {
   private String name;
   private int[] translateTo;
   private int writtenLang;
   private Project project;
   private List<Content> content;
   private Long id;
   
   public void removeTranslationLang(int lang){
      
   }
   public void setDocLang(int lang){
      
   }
   public void setId(Long id) {
      this.id = id;
   }
   
   @Id @GeneratedValue
   @Column(name="id")
   public Long getId() {
      return id;
   }
   public void setName(String name) {
      this.name = name;
   }
   
   @Column(name="name")
   public String getName() {
      return name;
   }
   
   public void setProject(Project project) {
      this.project = project;
   }
   
   @ManyToOne(cascade=CascadeType.ALL)
   @JoinColumn(name="project_fk")
   public Project getProject() {
      return project;
   }
   
   public String toString(){
      return getName();
   }
   public void setContent(List<Content> content) {
      this.content = content;
   }
   
   @OneToMany (mappedBy="document", cascade=CascadeType.ALL, orphanRemoval=true)
   public List<Content> getContent() {
      return content;
   }
}


struts.xml
************
Code:
   <action name="do-delete-document" class="net.translators.actions.document.DeleteDocumentAction">
      <interceptor-ref name="defaultAndloginVerifier"/>
      <result name="success" type="redirect">home</result>
      <result name="input">/organization/setup-project.jsp</result>
      <result name="error">/organization/setup-project.jsp</result>
      <result name="login" type="redirect">login-user</result>
   </action>


HQL output
*********
Code:
Hibernate:
    /*
from
    Document d
where
    d.project=1 */ select
        document0_.id as id2_,
        document0_.name as name2_,
        document0_.project_fk as project3_2_
    from
        DOCUMENTS document0_
    where
        document0_.project_fk=1


Full Error
************
Code:
Struts has detected an unhandled exception:
Messages:    
node to traverse cannot be null!
File:    org/hibernate/hql/ast/util/NodeTraverser.java
Line number:    63
Stacktraces
java.lang.IllegalArgumentException: node to traverse cannot be null!

    org.hibernate.hql.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:63)
    org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:280)
    org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182)
    org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
    org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:101)
    org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:80)
    org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
    org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
    org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
    org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)
    net.translators.actions.document.DeleteDocumentAction.execute(DeleteDocumentAction.java:23)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
    net.translators.interceptors.MyValidator.intercept(MyValidator.java:74)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    java.lang.Thread.run(Thread.java:662)
   



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.