aspose file tools*
The moose likes Object Relational Mapping and the fly likes During delete org.springframework.dao.InvalidDataAccessApiUsageException: object references Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "During delete org.springframework.dao.InvalidDataAccessApiUsageException: object references " Watch "During delete org.springframework.dao.InvalidDataAccessApiUsageException: object references " New topic
Author

During delete org.springframework.dao.InvalidDataAccessApiUsageException: object references

Shinu Pil
Greenhorn

Joined: Sep 02, 2005
Posts: 9
i have two mapping files Swon and project
these are the

and project


when i tried to delete the selected record using
getHibernateTemplate().delete(entity);

showing exception as
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: com.tel.it.model.Project;

i tried with cascade="all" not-null="false" but noluck
could any body help me as i am new to hibernate

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30775
    
156

Is it right? Do you have any code referencing Project directly that could be working with an object still?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1672
    
    7

As Jeanne said you are calling delete on a transient entity. This means you are trying to delete an entity that is not yet persisted (does not have an id). Also the use of Hibernate template is now discouraged. Take a look at the Spring documentation for the preferred approach.


[How To Ask Questions][Read before you PM me]
Shinu Pil
Greenhorn

Joined: Sep 02, 2005
Posts: 9
SHINU SHINU.R wrote:i have two mapping files Swon and project
these are the

and project


when i tried to delete the selected record using
getHibernateTemplate().delete(entity);

showing exception as
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: .it.model.Project;

i tried with cascade="all" not-null="false" but noluck
could any body help me as i am new to hibernate

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: During delete org.springframework.dao.InvalidDataAccessApiUsageException: object references