-->
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.  [ 3 posts ] 
Author Message
 Post subject: Delete() - delete all in my base
PostPosted: Fri Jun 14, 2013 9:27 am 
Newbie

Joined: Fri Jun 14, 2013 9:17 am
Posts: 3
Hello.

I have a simple code:

Code:
import DAO.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import savers.Unit;

public class Test {

    public static void main(String args[]) throws Exception {

        Session session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        Unit unit = (Unit) session.createCriteria(Unit.class)
                .add(Restrictions.eq("unitId", 608)).uniqueResult();

        session.delete(unit);
        session.getTransaction().commit();
    }
}


It must to delete row in table Unit where unitId = 608, and delete all dependencies in other tables.
But it delete ALL rows in Unit table and all dependent tables! Why?
Where I have to search solution?


Top
 Profile  
 
 Post subject: Re: Delete() - delete all in my base
PostPosted: Wed Jun 19, 2013 3:45 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
Hi,

Can you post the log?


Top
 Profile  
 
 Post subject: Re: Delete() - delete all in my base
PostPosted: Wed Jun 19, 2013 4:50 am 
Newbie

Joined: Fri Jun 14, 2013 9:17 am
Posts: 3
Hello, thanx for trying to help.
I use netbeans, and after a long time of trying to fix this problem I rebuild all entities and it started to work. I think it was something in annotations in entity.
tnx.


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

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.