Error 3004: Problem in mapping fragment starting at line [closed]

In my case am not allowed to modify existing tables but I discovered that when you add a new table with “Include foreign key columns in the model” checked in EF4 and the table doesn’t contain any foreign key relationships then you try to add a association it will trigger this error. Defining Constraints in … Read more

Hibernate recursive many-to-many association with the same entity

@ManyToMany to self is rather confusing because the way you’d normally model this differs from the “Hibernate” way. Your problem is you’re missing another collection. Think of it this way – if you’re mapping “author”https://stackoverflow.com/”book” as many-to-many, you need “authors” collection on Book and “books” collection on Author. In this case, your “User” entity represents … Read more

MapKey vs HasForeignKey Difference – Fluent Api

Both mappings will create exactly the same database schema with a non-nullable foreign key SomethingId and a referential constraint between the two related tables. The first mapping with MapKey is used when you don’t want to have the foreign key as a property in your model class. The type of association in this case is … Read more

Why should I avoid loops when designing relationships for a database?

There’s a really good treatment of relationship loops in chapter 3 of this paper (archive.org). Generally however, the most common issue with loops is consistency of redundant information. Consider the case (from the paper) where a parent has many children; each child attends a school. There is a third relationship between parent & school (‘parent … Read more

How does Hibernate detect dirty state of an entity object?

Hibernate uses a strategy called inspection, which is basically this: when an object is loaded from the database a snapshot of it is kept in memory. When the session is flushed Hibernate compares the stored snapshot with the current state. If they differ the object is marked as dirty and a suitable SQL command is … Read more

Turn off constraints temporarily (MS SQL)

— Disable the constraints on a table called tableName: ALTER TABLE tableName NOCHECK CONSTRAINT ALL — Re-enable the constraints on a table called tableName: ALTER TABLE tableName WITH CHECK CHECK CONSTRAINT ALL ——————————————————— — Disable constraints for all tables in the database: EXEC sp_msforeachtable ‘ALTER TABLE ? NOCHECK CONSTRAINT ALL’ — Re-enable constraints for all … Read more

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