Entity « Delete « JPA Q&A





1. JPA Delete with 2 Interlocking Entity Classes    stackoverflow.com

I have 2 EJB 3 Entity Beans:

@Entity
public class Organisation
{
 @Id
 @Column(length = 64)
 private String guid;

 private String name;

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
 @JoinColumn(name = "home_unit_fk", ...

2. delete hibernate entity question?    stackoverflow.com

i want to delete a row and cascade all foreign keys in hibernate i am new to hibernate and i want to know if there's a method to delete an entity>> session.delete(); like the session.save ...

3. hibernate restore deleted entities    stackoverflow.com

Is there a third-party library which add restore deleted entities feature? i need something like Hibernate envers which creates entities and map them to tables at runtime, but a lot simpler! ...

4. Hibernate JPA cascade delete issue    stackoverflow.com

For explaning my issue, I have created this simple project with two tables : item and order1 (with item having orderId as Foreign Key). Now when I try to delete a row ...

5. Hibernate - delete linked entity    stackoverflow.com

I have 2 entites:

@Entity
@Table(name="product")
public class Product {
    private Long id;
    private Set<Upgrade> upgrade;

    @Id
    @Column(name="id")
    public ...

6. Hibernate not deleting unreferenced entities    forum.hibernate.org

7. Delete entities without delete    forum.hibernate.org

Hi everybody, need your help please... My purpose is to delete entities with Hibernate without actually delete those entities from database. I.e., to mark those entities as deleted (e.g. using Boolean flag isDeleted within all entities base class). Moreover, I would like to take advantage of the cascading power built in Hibernate so any entity that is being deleted will cascade ...

8. mark entity as deleted but not delete it    forum.hibernate.org

9. Deleting Multiple Entities at once    forum.hibernate.org

I am new to Hibernate, cannot find the simple documentation of how to remove multiple entities at once. I see I can use entityManager.remove(Object obj), but if I have a collection (ie: I can query a list) I would rather not loop through and make a delete call on each individual id. I can use native sql as it is a ...





10. Entity history - Logical Delete Pattern ??    forum.hibernate.org

We use something similiar, although we do not utilize the "where" attribute of the hibernate mapping for it. Basically a bunch of our tables have a column named "active_flg" where true (1) indicates the record is still active and false (0) indicates it is no longer active. So none of these records ever gets deleted. Instead its active_flg column simply gets ...

11. Entity history - Logical delete design pattern ??    forum.hibernate.org

Hi, I'm not sure this is helpful, but I have tried to solve the problem of reversible deletes, or tiered deletes where sometimes you can only flag an entity as deleted, without removing it from the db, and sometimes you can actually delete it from the db. I created an interface for such classes of entities so that the process of ...

12. Entity delete sign    forum.hibernate.org

Hibernate version: 3.0.3 Hello, Please help me! How can I sign my entities that was deleted (isTransient()=true, maybe id=null) by Hibernate. I can't do this manullay because the Hibernate deletes some entities over cascading. I try to use the Interceptors but I don't know is it good to set the id property to null in the onDelete method. I thought I ...

13. Delete entity in large collections    forum.hibernate.org

Generally if you have too many children to safely load into memory, I find there to be little reason to even *have* the parent-side association. In other words: why do you even have an items collection as part of customer, if it's possible for a customer to have so many items that customer.getItems().() will probably cause an immediate OutOfMemoryException? In this ...

14. Deleting the m2m link, not the entity    forum.hibernate.org

hello, I use hibernate3 and I have mapped a bidirectionnal many-to-many relationship: A *--------------* B In database, I have: A(idA), B(idB) and AB(idA, idB) How can I delete the link AB without deleting A or B For example, I would like to delete A, and delete cascade from AB but not to delete B. I there any solution to do this, ...

15. Unexpected update action when deleting entity    forum.hibernate.org

Newbie Joined: Fri Dec 30, 2005 9:19 am Posts: 3 Location: Buenos Aires I am working with Hbm 3.0.5 and I can't undestand why Hibernate is performing an UPDATE when flushing the Session when the only action performed by me was a DELETE. I am 99 percent sure I am not modifying the entity or any entity in its graph at ...

16. Problem deleting entity in hierarchy    forum.hibernate.org

Newbie Joined: Mon Jul 24, 2006 4:25 pm Posts: 2 Hi, I'm using Hibernate 3.2.0 CR2 and when I try to delete entities in batch (with an HQL query), I got an error in the SQL translation of my query. I try to delete an entity that is the child of another one. Here are my mapping files: Scancode (parent entity)...... ...





17. on-delete="cascade" and collection/entity caches    forum.hibernate.org

Does on-delete="cascade" work with entity and collection caches? For example, if we have object 'A', 'B' and 'C'. Objects 'B' and 'C' are members of one-to-many collection in 'A' with cascaded delete. Now, suppose we have object 'C' in second-level cache and issue 'delete' statement on object 'A'. Database will delete objects 'B' and 'C'. But as far as I understand, ...

19. Newbie: implementing cascading delete for linked entities?    forum.hibernate.org

I have a question about the validity of using cascading delete Hibernate definitions. My example involves two entities 'Customer' and 'Order'. My Hibernate design envisages these as being two discrete hibernate mappings. Although a customer is associated with an order (the order table will include a 'customer ID' foreign key column), the orders are not defined at the same or place ...

20. How can I auto delete all created entities in the VM.    forum.hibernate.org

Hi, I want to increase the performance of my integration tests. The servlet engine is run in the same VM as the tests. This means that I have a main thread, with a Session bound to it, inserting test data upon setup. It also means that I will have Servlet worker threads creating data in other Sessions in response to actions ...

21. Deleting an entity from a collection: DELETE_ORPHAN?    forum.hibernate.org

farzad wrote: What is the mapping for the one that doesn't work? OK, here it is (sorry for that late response, I was lying ill in bed last days) first, this is the mapping which does not work as I expect it: (a Contact may be the owning parent of several BankAccount objects: Code: class BankAccount { .... @ManyToOne @JoinColumn(name = ...

22. data deleted and no entity found!    forum.hibernate.org

Hi, I have just started using hibernate and I have a simple application that creates a few tables, (POJO classes mapped) and inserting data in the tables , so far this is successfull. I end the application and start a new test program: I initialize (EntityManagerFactory emf = Persistence.createEntityManagerFactory("hibernatetest"); EntityManager = emf.createEntityManager(); ) and next I do a query upon the ...

23. Please any help - EJB5018 with EM on entity delete    forum.hibernate.org

I have attempted to search thru the discussions on this but have not found anything I am using netbeans6.0.1 for dev Glassfish V2 Postgres 8.1.10 JPA at the EJB tier uses Hibernate EntityMananger 3.3.2 to wrk with the DB I have a table Reminders (well it is suppose to keep track of reminders for a user). My app has a web ...

24. delete a self referenced entity    forum.hibernate.org

Author Message pr0grammer Post subject: delete a self referenced entity Posted: Tue Nov 04, 2008 2:57 am Newbie Joined: Fri Sep 26, 2008 4:45 am Posts: 17 Hi, I've the following entity : Code: package ch.btc.datec.yamina.model; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import ...

25. Howto only delete un-referenced entities with cascade?    forum.hibernate.org

public class Peer implements Serializable{ ........ @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE }) private Set files = new HashSet(); } public class SharedFile implements Serializable { ............. @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE }) private Set peers = new HashSet();

26. Cannot delete from many-to-many with intermediate entity    forum.hibernate.org

Author Message CWertz Post subject: Cannot delete from many-to-many with intermediate entity Posted: Thu Jan 15, 2009 8:12 pm Newbie Joined: Thu Jan 15, 2009 7:27 pm Posts: 4 Location: Boulder, CO Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp I have a program that has application objects, and each application is both a client and a ...

27. Many-to-one owner to cascade on deletion of owned entity    forum.hibernate.org

Hi there, my task is to delete an entity B that holds a many-to-one reference to an entity A as soon as the referenced entity A is deleted -- basically a cascade delete in the DB. The association is unidirectional and entity A does not "know" about entity B. Java code: Code: public abstract class RootEntity { private Long ...