table « Delete « JPA Q&A





1. hibernate always deletes all data from a table on its own    stackoverflow.com

Hi i am developing a spring mvc app thats using hibernate to connect to a mysql database that stores files. I have two methods. one that adds all files from a specific ...

2. Cascade delete from the same table    stackoverflow.com

Hi I am using JPA2 with Hibernate implementation and I got a simple mapping like this :

@Entity
@Table(name = "users")
public class User {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Integer ...

3. How to delete all entries in a table    stackoverflow.com

My named query looked like this delete from User u without a where clause, but it didn't delete anything on a Query.executeUpdate()

4. Hibernate @OnDelete cascade same table    stackoverflow.com

I am trying to create a table which captures parent child relationships, like a tree. I would like to maintain only two columns to capture this structure "id" and "parent". I ...

6. One To Many using Link Table - does nt Cascade delete    forum.hibernate.org

Hi , I am trying to model a One To Many relationship using a Link Table (aka Join Table) - and I am struggling with a Cascade delete that goes horribly wrong. I am using JPA with Hibernate Annotations Entity classes are a) Project.java , b) Employee.java . A project can have many employees in it . Hence a Project will ...

7. Best way to delete data in a table?    forum.hibernate.org

I have two tables A & B. A has a one-to-many relationship with B, and also keeps a many-to-one relationship to record the last B element. B keeps a many-to-one reference back to A as the parent entity. A id = 1 lastB = 2 B id = 2 A = 1 As part of my test environment, I have an ...

8. How do I delete an entire table?    forum.hibernate.org

9. How to delete a many-to-many link table?    forum.hibernate.org

Class Department { ... private Set students; .... } Class Student { ... private Set depts; .... } Now, if I want to delete entries related to a particular Department using HQL, can I do the following: "delete from Department.students ......" or //define values and types ..... String hql = "select dept.students from Department as dept ....."; session.delete(hql, ...





10. hibernate delete all data in linked table    forum.hibernate.org

Hello, I have a old shema database. Each table have a composite-id. there is a relation many-to-many between 2 tables (C_OFFOPTTIT et C_TARIFS). Hibernate delete all data in the linked table when I load a table. what can i do to resolve my problem. Leto List listOffOptTit = baseDAOHibernate.getHibernateTemplate().find("from OffOptTit"); Hibernate version :2

11. Creates work but updates and deletes don't on any table    forum.hibernate.org

Hibernate version:3 I have a simple test case that creates a row, updates another and deletes another. The create works find but the amendment to the second row and the delete don't get to the database. Session session = HibernateUtil.currentSession(); Transaction transaction = session.beginTransaction(); Person person2 = (Person) session.get(Person.class, "grape"); person2.setName("pip"); Person person3 = (Person) session.get(Person.class, "peach"); session.delete(person3); session.merge(person); session.merge(person2); transaction.commit(); ...

12. Delete values in another table    forum.hibernate.org

Hi, I've a table which holds the primary key(ACL_TABLE) of 5 other tables in one column. The 5 other tables don't have any foreign-key contraint with the ACL_TABLE table. Now, whenever a record in the 5 other tables is deleted, I want the corresponding record in this table deleted as well. However, my application does not know when the 5 other ...

13. How to auto drop or delete tables?    forum.hibernate.org

I have a properties file that determines which server of two I have to access data. The server will be either in development or production and they all contain different test data. The problem I have is that if I access a dev database and then alter my properties file to point to prod, all of the cached data I am ...

14. Hibernate starts deleting from "wrong" table    forum.hibernate.org

I have a problem with deleting an object with Hibernate. The mapping is this: Class Report Code:

15. Delete table contents    forum.hibernate.org

I am having trouble in Hibernate 3 deleting all rows in the table. The HQL: 'DELETE FROM TABLE_NAME' throws this exception: org.hibernate.QueryException: query must begin with SELECT or FROM: DELETE [DELETE FROM Users] at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:83) at org.hibernate.hql.classic.PreprocessingParser.token(PreprocessingParser.java:108) at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:28) at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:191) at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:167) at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:75) at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:54) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71) 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:1583) Any insight would be greatly appreciated. ...

16. MSSQL: two on-delete="cascade" on same table.    forum.hibernate.org

Newbie Joined: Thu Feb 08, 2007 6:38 am Posts: 1 Location: Belarus Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.1.1 Mapping documents: I have persistent class Job





17. cascade delete not iterating more than 3 tables    forum.hibernate.org

I have 4 tables Customer has one-to many relation with Orders Orders has many-to-one relation with Customer Orders has one-to-many relation with LineItem LineItem has many-to-one relation with Orders LineItem has one-to-many relation with ItemConf ItemConf has many-to-one relation with LineItem all above are bidirectional table got generated and all foreignkey relations are eastablished correctly. i am able to insert and ...

18. buildSessionFactory deletes my table    forum.hibernate.org

Hibernate version: 3.0 Mapping documents: Code: org.hibernate.dialect.MySQLDialect ...

19. Problem delete tables    forum.hibernate.org