Add @Polymorphic [moved]
See original GitHub issueThis is Issue 22 moved from a Google Code project. Added by 2010-03-31T16:32:45.000Z by scotthernandez. Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Enhancement, Priority-Medium, Milestone-Release1.1
Original description
Add support for storing (and searching on) the whole super-class tree and the interfaces implemented
on any of them. Most likely this will be stored as an array of strings called super-classes
(including the current class-name).
Something like this should be supported:
@Polymorphic
public class Shape {
}
public class Circle extends Shape {
}
public class Square extends Shape {
}
Datastore ds = ...;
List<Shape> shapes = ds.find(Shape.class).asList()
for(Shape shape : shapes)
print(shape.getClass().getName());
> Circle
> Square
> Shape
> Circle
> Circle
Issue Analytics
- State:
- Created 10 years ago
- Comments:20 (3 by maintainers)
Top Results From Across the Web
Rails Techniques: Using Polymorphic Associations - Semaphore
Add flexibility to your Rails models using Polymorphic Associations - Active Record associations that ... Moving on to the implementation.
Read more >rails polymorphic add using << - Stack Overflow
My new rails 4.1 project has the following polymorphic associations. class Order < ActiveRecord::Base has_many :line_items, ...
Read more >Changing a polymorphic_type in Rails — Development (2022)
Not storing class names as polymorphic types means you can move your classes, rename your modules and classes, without having to touch your ......
Read more >Polymorphic associations with Ruby on Rails - like all the things
In this episode, you'll learn how to migrate from a one to many association to a polymorphic association. Imagine you've implemented a like ......
Read more >Polymorphic Associations - GitLab Docs
Rails makes it possible to define so called “polymorphic associations”. This usually works by adding two columns to a table: a target type...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I actually have this done in my fork that I’m working on. I’ve replaced the mapping code with the driver’s POJO stuff i helped write. It’s getting pretty close to done.
working now in 2.0 though the
@Polymorphic
annotation isn’t necessary.