cascade={“remove”} VS orphanRemoval=true VS ondelete=”CASCADE

onDelete=”CASCADE” is managed by the database itself. cascade={“remove”} is managed by doctrine. onDelete=”CASCADE” is faster because the operations are performed on database level instead by doctrine. The removing is performed by the database server and not Doctrine. With cascade={“remove”} doctrine has to manage the entity itself and will perform extra checks to see if it … Read more

Improving bulk insert performance in Entity framework [duplicate]

There is opportunity for several improvements (if you are using DbContext): Set: yourContext.Configuration.AutoDetectChangesEnabled = false; yourContext.Configuration.ValidateOnSaveEnabled = false; Do SaveChanges() in packages of 100 inserts… or you can try with packages of 1000 items and see the changes in performance. Since during all this inserts, the context is the same and it is getting bigger, … Read more

what is difference between a Model and an Entity

The definition of these terms is quite ambiguous. You will find different definitions at different places. Entity: An entity represents a single instance of your domain object saved into the database as a record. It has some attributes that we represent as columns in our tables. Model: A model typically represents a real world object … Read more

What is the difference between persist() and merge() in JPA and Hibernate?

JPA specification contains a very precise description of semantics of these operations, better than in javadoc: The semantics of the persist operation, applied to an entity X are as follows: If X is a new entity, it becomes managed. The entity X will be entered into the database at or before transaction commit or as … Read more

How to set a default entity property value with Hibernate

If you want a real database default value, use columnDefinition: @Column(name = “myColumn”, nullable = false, columnDefinition = “int default 100”) Notice that the string in columnDefinition is database dependent. Also if you choose this option, you have to use dynamic-insert, so Hibernate doesn’t include columns with null values on insert. Otherwise talking about default … Read more

How to fix the Hibernate “object references an unsaved transient instance – save the transient instance before flushing” error

You should include cascade=”all” (if using xml) or cascade=CascadeType.ALL (if using annotations) on your collection mapping. This happens because you have a collection in your entity, and that collection has one or more items which are not present in the database. By specifying the above options you tell hibernate to save them to the database … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)