Inheritance / Polymorphism
See original GitHub issueGiven 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:
- Created 7 years ago
- Comments:5
Top 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 >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
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!
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.