single-table-inheritance Questions

1

Is it possible to set-up a scope on a single table inheritance that returns the subclass? For example: class Post < ActiveRecord::Base scope :sticky, -> { where(type: 'StickyPost') } end ...
Forrestforrester asked 18/9, 2013 at 9:58

3

Solved

I've been playing around with STI and belongs_to / has_many relationships and I'm a bit confused. I have a few questions based on a model configuration similar to: class Parental < ActiveRecor...

2

Solved

I'm trying to migrate an application from Hibernate 3.4.0.GA to Hibernate 5.1, and after complete the required changes on java code, when I deploy the application I'm watching how Hibernate is tryi...
Alexander asked 23/3, 2016 at 8:23

4

Solved

I have setup a role based access controll system with the following models: Role (as STI), UserRole (global roles) ProjectRole (project specific roles) Assignment (Polymorphic with different r...

18

My Rails views and controllers are littered with redirect_to, link_to, and form_for method calls. Sometimes link_to and redirect_to are explicit in the paths they're linking (e.g. link_to 'New Pers...
Inlaid asked 22/12, 2010 at 7:45

4

Solved

I'm currently using ActiveRecord single table inheritance. How can I cast one of my models from type A to B? They have the same parent.

6

Solved

Is there explicit support for Single Table Inheritance in Django? Last I heard, the feature was still under development and debate. Are there libraries/hacks I can use in the meantime to capture ...
Eximious asked 27/10, 2008 at 20:18

2

Solved

I have a Card model that has many CardSets and a CardSet model that has many Cards through a Membership model: class Card < ActiveRecord::Base has_many :memberships has_many :card_sets, :throu...
Antherozoid asked 10/6, 2010 at 21:0

1

Solved

I am using single table inheritance strategy. I want to perform a search in the database by filtering it using the discriminator type. How am I to write a function in JPA to perform this operation....

6

Solved

We have the following classes @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // optional annotation as this is default @DiscriminatorColumn(name = "apType", discriminatorType = Disc...
Semilunar asked 9/6, 2010 at 11:34

1

Solved

tl;dr Is there a simple alternative to multi-table inheritance for implementing the basic data-model pattern depicted below, in Django? Premise Please consider the very basic data-model pattern ...

7

Solved

I have a whole bunch of child classes that inherit from a parent class via single-table-inheritance in my Rails app. I'd like a way to get an array of all the child classes that inherit from the ma...
Hohenzollern asked 10/5, 2012 at 13:54

2

Solved

Using Python 3.5 and SQLAlchemy 1.0.14 (ORM). I have a table of items declared as such: from sqlalchemy.ext.declarative.api import declarative_base Base = declarative_base() class Item(Base): ...
Weitzman asked 21/7, 2016 at 12:7

6

Solved

Because of company rules I can't use our domain class names; I am going to use an analogy instead. I have a table called projects which has a column called 'type' with possible values as 'indoor' &...
Kendallkendell asked 25/4, 2014 at 12:26

7

Solved

In my application, I have a class called Budget. The budget can be of many types.. For instance, let's say that there are two budgets: FlatRateBudget and HourlyRateBudget. Both inherit from the cla...
Hypnogenesis asked 10/2, 2012 at 14:46

2

Solved

I'm reading about Class Table Inheritance (CTI) and finding I prefer it overall. The question I have is, is there any specific use case for Single Table Inheritance (STI) where you'd use that over ...

1

Solved

I have the following models using Single Table Inheritance (STI) in Rails 4: class User < ActiveRecord::Base has_many :notes end class Item < ActiveRecord::Base end #inherits from Item cl...
Nystatin asked 20/1, 2018 at 1:27

7

Given a model class BaseModel < ActiveRecord::Base validates_presence_of :parent_id before_save :frobnicate_widgets end and a derived model (the underlying database table has a type field -...
Acerbity asked 10/11, 2008 at 22:52

2

Solved

In my database I have a table people, and I'm using single table inheritance, with these classes: class Person < ActiveRecord::Base end class Member < Person end class Business < Member...
Singularize asked 8/10, 2015 at 3:25

6

Solved

I am using the following feature from propel http://www.propelorm.org/documentation/09-inheritance.html. I am also using Symfony2 and Twig I have a class structure using the above feature that lo...
Cupboard asked 11/4, 2012 at 20:28

5

Solved

I want to use a column called type without invoking Single Table Inheritance (STI) - I just want type to be a normal column that holds a String. How can I do this without having Rails expecting me...
Prestidigitation asked 20/8, 2011 at 20:41

4

I'm using Hibernate 3.2.2 GA with HSQLDB 2.0 GA, and I have a class hierarchy similar to the following: @Entity @Table(name = "A_TABLE") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @Disc...
Chaste asked 14/4, 2011 at 18:15

0

These are the options I see that can help solve "Rails 5 - Object Relation Impedence and how to structure multiple inherited classes/tables" TL;DR - the Object Table Impedance ORM problem. Abstra...

2

I have read the posts here, here, and here, but I'm still having trouble with implementing Single Table Inheritance. Ideally I would like to have two registration paths (one for clients and one fo...

3

Solved

I have following inheritance hierarchy: Task | SpecificTask | VerySpecificTask And I'd like to persist it usign single-table inheritance, so I annotated classes: @Entity @Table(name="task") @...

© 2022 - 2024 — McMap. All rights reserved.