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.

Inheritance / Polymorphism

See original GitHub issue

Given than i have these models:

public class Zoo {
  private int id;
  private Date openning_hour;
  private Date closing_hour;
  private String manager;
  private ArrayList<Animal> animals;
}

public abstract class Animal  {
  private String name;
  private int zoo_id;
}

public class Dog extends Animal {
  private boolean canSmellFromFar;
}

public class Spider extends Animal {
  private boolean bites;
}

and if i have two tables (Zoo, Animal), and we have a Query getAllAnimalIntTheZoo(int zooId). can it return sub-types of Animal?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
gabrielpaimcommented, May 26, 2019

Hi there,

I’d like to know if is there any update on this. Is there any plans for SqlDelight to support polymorphism/inheritance?

@AlecStrong Would you still recommend the same approach to deal with this still? That is, joining all inherited tables into a single view and treating it on mapper as a STI. I find it somehow uncomfortable, but maybe it still remains as good strategy to deal with it.

Thank you!

1reaction
AlecStrongcommented, Oct 13, 2016

If you mean the generated *Model.java files then no, those shouldn’t be checked in (as they exist under the generated folder). If you mean the files you write which implement *Model then yes, those should be checked in.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between Inheritance and Polymorphism
1. Inheritance is one in which a new class is created (derived class) that inherits the features from the already existing class(Base class)....
Read more >
Understanding Java Inheritance and Polymorphism - Section.io
In inheritance, we create new classes that inherit features of the superclass while polymorphism decides what form of method to execute.
Read more >
5.4: Difference between Inheritance and Polymorphism
1. Inheritance is one in which a new class is created (derived class) that inherits the features from the already existing class(Base class)....
Read more >
What is the main difference between Inheritance and ...
Polymorphism is an effect of inheritance. It can only happen in classes that extend one another. It allows you to ...
Read more >
Inheritance, Encapsulation and Polymorphism
There are three more important concept, inheritance, which makes the OOP code more modular, easier to reuse and build a relationship between classes....
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