aspose file tools*
The moose likes Object Relational Mapping and the fly likes @ManyToMany delete problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "@ManyToMany delete problem" Watch "@ManyToMany delete problem" New topic
Author

@ManyToMany delete problem

Roberto Lopez Lopez
Greenhorn

Joined: Jun 16, 2008
Posts: 22
Hi guys.

I'm dealing with a jpa based app and my basic knowledge doesn't allow me to successfully delete an entity.

I try the following code:

But when I create the query, an exception is thrown:

10:50:44,321 INFO [STDOUT] 2008/09/12 10:50:44 ERROR hibernate.hql.PARSER[http-127.0.0.1-8080-1]: line 1:58: unexpected token: join
java.lang.IllegalArgumentException: node to traverse cannot be null!
at org.hibernate.hql.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:31)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:254)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:92)
at es.encore.nollego.comun.dao.subcategoria.SubcategoriaDAO_HBM.deleteByNick(SubcategoriaDAO_HBM.java:206)
... 34 more


It seems the problem is the join clause, but I've tried in several ways but didn't succeed. Can anybody help me with this issue?

Here you have the entities:



Previously I've successfully done a select:



Thanks in advance...
Roberto Lopez Lopez
Greenhorn

Joined: Jun 16, 2008
Posts: 22
I've changed my code but still no results.



The executeUpdate() method throws the following:
org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [
bdd.subcategoria.compras.alimentacion,
es.encore.nollego.comun.to.UsuarioTO[...]
]
[delete from SubcategoriaTO sc where sc.subcategoria=? and sc.usuarios=?]


Where's the problem?
Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
I'm not sure if this helps......

More from the dumbass mistake department. Trying to boot up a Hibernate based project, I was getting this error:

java.lang.IllegalArgumentException: node to traverse cannot be null!

This was occurring during parsing of the named query information in the configuration. Eventually I tracked it down to this query:

@NamedQuery(
name=Comment.COUNT_COMMENTS_BY_ARTICLE,
query="count(*) from Comment where article = :article")

The problem was simply that I'd omitted a vital keyword from the query - because I'm normally retrieving lists of simple entities with queries of the form "from Foo where bar = :spong", which is quite legal, I failed to spot the missing select for ages even where it was staring me in the face! Here's that corrected query:

@NamedQuery(
name=Comment.COUNT_COMMENTS_BY_ARTICLE,
query="select count(*) from Comment where article = :article")

it was taken from....
Node to traverse cannot be null
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @ManyToMany delete problem