question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add @Polymorphic [moved]

See original GitHub issue

This 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:closed
  • Created 10 years ago
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
evanchoolycommented, Jun 8, 2018

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.

0reactions
evanchoolycommented, Oct 16, 2019

working now in 2.0 though the @Polymorphic annotation isn’t necessary.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found