discriminator

How to Automatically Map TPH Derived Classes in EF Core?

雨燕双飞 提交于 2021-01-27 23:11:51
问题 By default, EF6 would map a base abstract class and it's derived classes for Table Per Hierarchy (TPH). EF Core no longer follows this logic and requires derived classes to be opted in. The documentation states: By convention, types that are exposed in DbSet properties on your context are included in the model as entities. Entity types that are specified in the OnModelCreating method are also included, as are any types that are found by recursively exploring the navigation properties of other

How to select discriminator column in doctrine 2

China☆狼群 提交于 2019-12-30 18:57:05
问题 I need some help when select only discriminator column from doctrine 2 when run the DQL below SELECT p.type FROM AppBundle\Entity\Product p type is discriminator column in entity AppBundle\Entity\Product @ORM\DiscriminatorColumn(name="type", type="smallint")` @ORM\DiscriminatorMap({ "0" = "AppBundle\Entity\Product", "1" = "AppBundle\Entity\Product\SingleIssue", "2" = "AppBundle\Entity\Product\CountBasedIssue", "3" = "AppBundle\Entity\Product\TimeBasedIssue" }) I know that type is not a real

Spring-Data JPA with Multi-Tenancy Hibernate

断了今生、忘了曾经 提交于 2019-12-30 03:26:28
问题 I am trying to get Spring-Data JPA working with Hibernate with a custom MultiTenantConnectionProvider. Everything in my configuration below seems to work. My MultiTenantConnectionProviderImpl class gets called each time I try to call a Repository method. The main problem is that there is no way to provide a tenant identifier. The Repository interfaces provided by Spring-Data take care of getting the Hibernate Session. Is there any way to provide Spring-Data the tenant identifier? Or is there

Cannot rename Discriminator column in Entity Framework 4.1 Code First database

前提是你 提交于 2019-12-23 16:26:14
问题 I have a model hierarchy configuration like so: [Table("A")] abstract class A { } class B : A { } // treated as abstract [Table("C")] class C : B { } This results in a TPH for A and B, and a TPT for C. So far this seems to work fine. There are two database tables being generated: "A" which contains both A and B model records, and "C" which contains only C model record columns not already kept in table "A". For the TPH arrangement on Table A, there is a generated "Discriminator" column, which

Why is @DiscriminatorColumn ignored when using @JoinTable?

半城伤御伤魂 提交于 2019-12-23 15:36:26
问题 Suppose I have the following tables: ______________________ | LAWSUIT | |______________________| | ID | | TITLE | |______________________| \ \ \ ______________________ | PERSONS_IN_THE_CASE | |______________________| | ID_LAWSUIT | | ID_PERSON | |______________________| / / / ______________________ | PERSON | |______________________| | ID | | NAME | | TYPE | TYPE values = "Plantiff, Defendant, Lawyer, Judge, ..." |______________________| (I know that normalizing the database I could have a

Hibernate 4: persisting InheritanceType.JOINED discriminator column values

无人久伴 提交于 2019-12-18 04:03:35
问题 I have a simple JOINED hierarchy of documents: CREATE TABLE Documents ( id INTEGER NOT NULL, discriminator ENUM('official','individual','external') NOT NULL, file_name VARCHAR(200) NOT NULL, PRIMARY KEY (id) ); CREATE SystemDocuments ( id INTEGER NOT NULL, binary_data BLOB NOT NULL, PRIMARY KEY (id), FOREIGN KEY (id) REFERENCES Documents (id) ); CREATE ExternalDocuments ( id INTEGER NOT NULL, PRIMARY KEY (id), FOREIGN KEY (id) REFERENCES SystemDocuments (id) ); As you can see all the sub

how to make tablePerHierarchy false and use discriminator?

这一生的挚爱 提交于 2019-12-13 05:02:46
问题 A question like what I need is asked here but it's answer is not satisfying what I need. I have classes like this : abstract class A{ String a } class B extends A{ String b } class C extends A{ String c } I want to have a table for each class, so I add tablePerHierarchy and set it false like this: abstract class A{ String a static mapping = { tablePerHierarchy false } } but when I run the program and it creates a database there are no discriminator, and I want to query table A and find out if

How can I change Discriminator (__Disc__) field while it is used as a condition

断了今生、忘了曾经 提交于 2019-12-12 22:54:26
问题 I have to update and change Discriminator( _ Disc _ ) field of a table while mapped entities doesn't have it as an entity member . any solution? 回答1: Discriminator column is used to define type of entity in TPH inheritance and EF cannot change it - never. It is like inheritance in any object oriented language - once you define object of some type you cannot make it different type - you can only cast it to parent but it will still be instance of original type. The only way to change it to

JPA multiple discriminator values

梦想与她 提交于 2019-12-12 15:39:09
问题 We're setting up a new project and decided to use eclipselink for JPA. When creating our domain model we ran into a problem. We have a base class called organisation. We also have Supplier and Customer which both extend organisation. When JPA created the tables I saw that it uses a discriminator, the problem with this is that a supplier can also be a organisation. So what I basically want is (these are database tables to get the idea): A little example to help clarify this: We have a Customer

Using C# MongoDB LINQ with discriminator

谁说胖子不能爱 提交于 2019-12-12 10:43:17
问题 I have a single MongoDB collection holding documents of three different classes (A,B,C) which all inherit from a common class D. Using the official C# driver, I have inserted documents of all three types (A,B,C) and they all appear correctly with the _t discriminator, and in my code their class maps are registered. If I issue a LINQ query such as the following (using VB): dim Result = database.GetCollection("mycol").AsQueryable(Of C).Where(some where clause) If I count the results of this, I