discriminator

Discriminator column mapped as entity Hibernate

。_饼干妹妹 提交于 2019-12-12 08:57:08
问题 In hibernate, is it possible to have discriminator as an entity? For example, if I have Department as the base class & AdminDepartment & ProcessingDepartment as subclasses. DepartmentType is the discriminator & is an entity mapped to DEPT_TYPE table. 回答1: Yes, it's possible, though such a relationship will be read-only: @Entity @Inheritence(...) @DiscriminatorColumn(name = "DEPT_TYPE_ID") public class Department { ... @ManyToOne @JoinColumn(name = "DEPT_TYPE_ID", insertable = false, updatable

Doctrine 2 Discriminator Inheritance Mapping leads to findBy methods not working

ε祈祈猫儿з 提交于 2019-12-12 05:37:48
问题 i have 2 entities, one as a main super class which consist of the discrimators etc and one which extends this super class... so that i can record all actions in one table called Action. my discrimator entity: namespace Entities\Members; /** * @Entity * @Table(name="actions") * @MappedSuperClass * @InheritanceType("JOINED") * @DiscriminatorColumn(name="action_type", type="string") * @DiscriminatorMap({"comments" = "Comments", "blog" = "Blog"}) * @HasLifecycleCallbacksIndex */ class Action { /*

Symfony: Forms with inherited classes

﹥>﹥吖頭↗ 提交于 2019-12-12 03:06:28
问题 I'm trying to figure out how to handle forms when using inherited class types with Symfony (2.8.6). I have created a [very] simple example case of what I'm trying to do below. There are problems with it, but it's only to illustrate my question. How can I supply just one form going from the controller to a twig template so that there can be a field to choose what "type" (discriminator) should be used? Should I simply create another variable, such as "type" that is hardcoded in each class? Once

How to get a list of available Mongoose Discriminators?

心不动则不痛 提交于 2019-12-10 02:54:14
问题 Given a situation where you have a User Scheme that you use to create a base model called User. And then for user roles, you use mongoose discriminators to create inherited models called Admin, Employee and Client. Is there a way to programmatically determine how many discriminations/inheritances/roles of the User model are available, as well as the available names? My question in terms of code: File : models/user.js var mongoose = require('mongoose'); var Schema = mongoose.Schema; var

DISCRIMINATOR based Multi-Tenancy with Spring Data JPA+Hibernate

半世苍凉 提交于 2019-12-09 16:40:53
问题 I want to implement DISCRIMINATOR based Multi-Tenancy solution for Shared Schema Based Multi-Tenancy Model -common database schema for all tenants. Technology stack Hibernate 3 Global filter (I can't use EclipseLink) Spring Data JPA - I want this because we are already using this one and we cant change it. My questions are How to achieve this : Spring Data JPA has no any support for GLOBAL filter so I need to add customize Spring Data JPA repository which can in-turn apply global filter for

How to get a list of available Mongoose Discriminators?

限于喜欢 提交于 2019-12-05 02:29:10
Given a situation where you have a User Scheme that you use to create a base model called User. And then for user roles, you use mongoose discriminators to create inherited models called Admin, Employee and Client. Is there a way to programmatically determine how many discriminations/inheritances/roles of the User model are available, as well as the available names? My question in terms of code: File : models/user.js var mongoose = require('mongoose'); var Schema = mongoose.Schema; var options = {discriminatorKey: 'role'}; var userSchema = mongoose.Schema({ name: String, email: String,

Discriminator column mapped as entity Hibernate

↘锁芯ラ 提交于 2019-12-04 14:23:41
In hibernate, is it possible to have discriminator as an entity? For example, if I have Department as the base class & AdminDepartment & ProcessingDepartment as subclasses. DepartmentType is the discriminator & is an entity mapped to DEPT_TYPE table. Yes, it's possible, though such a relationship will be read-only: @Entity @Inheritence(...) @DiscriminatorColumn(name = "DEPT_TYPE_ID") public class Department { ... @ManyToOne @JoinColumn(name = "DEPT_TYPE_ID", insertable = false, updatable = false) private DepartmentType deptType; ... } 来源: https://stackoverflow.com/questions/10273975

How to select discriminator column in doctrine 2

北慕城南 提交于 2019-12-01 17:52:19
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 property in entity, but is there anyway for me to do that? Thanks in advance! Updated After 2 days for

EclipseLink JPA inheritance without discriminator column

我与影子孤独终老i 提交于 2019-11-30 18:04:21
问题 I have a Client and Affiliate class, inheriting from Person class. Joined inheritance strategy type is being used - each of them sharing primary key with the parent class. As there's no discriminator column we chose to use DescriptorCustomizer and ClassExtractor. But it doesn't really give any idea how it works, also, the code doesnt seem to compile. It would be nice if someone gives a nice example with code snippet for understanding. 回答1: According to the mentioned documentation: If you are

Doctrine 2 - How to use discriminator column in where clause

随声附和 提交于 2019-11-30 12:26:43
问题 I was used discriminator column in where clause like this: //f = root entity $qb = $this->createQueryBuilder('f'); $qb->add('where', 'f.format = \'image\' OR f.format = \'text\''); I've got an error: "Message: [Semantical Error] line 0, col 73 near 'format = 'image'': Error: Class Entities\File\AbstractFile has no field or association named format" How can i use discriminator column in where clause? Thanks. 回答1: I think that you should use INSTANCE OF 回答2: It would look in query builder like