File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

@ManyToMany delete problem

Roberto Lopez Lopez

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-]: line 1:58: unexpected token: join
java.lang.IllegalArgumentException: node to traverse cannot be null!
at org.hibernate.hql.ast.util.NodeTraverser.traverseDepthFirst(
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(
at org.hibernate.engine.query.HQLQueryPlan.<init>(
at org.hibernate.engine.query.HQLQueryPlan.<init>(
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(
at org.hibernate.impl.AbstractSessionImpl.createQuery(
at org.hibernate.impl.SessionImpl.createQuery(
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(
at es.encore.nollego.comun.dao.subcategoria.SubcategoriaDAO_HBM.deleteByNick(
... 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

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: [
[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:

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:

query="select count(*) from Comment where article = :article")

it was taken from....
Node to traverse cannot be null
I agree. Here's the link:
subject: @ManyToMany delete problem
It's not a secret anymore!