Custom getters with Global Database object removed
See original GitHub issueI’ve been trying Ktorm 2.7-RC that you uploaded after my request (thank you!).
In practice, I’ve found the new way of using Ktorm quite uncomfortable as now I’ve to pass around a database object. While this is doable, one place where I’ve been struggling with the new APIs is the custom setters. A while back you gave us an example of using a custom getter inside an entity interface:
interface Department : Entity<Department> {
val id: Int
val name: String
val employees get() = Employees.findList { it.departmentId eq id }
}
Do you have an idea how to achieve this with the new API?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Lombok how to customise getter for Boolean object field?
I have declared @Data at class level and have too many attributes in the class, so excluding getter or making the default getter...
Read more >Property getters and setters - The Modern JavaScript Tutorial
Accessor properties are represented by “getter” and “setter” methods. In an object literal they are denoted by get and set :.
Read more >Best Practices for Java Getter and Setter - DZone
In this post, we take a closer look at getter and setter methods in Java, common mistakes, and best practices for combating these...
Read more >getter - JavaScript - MDN Web Docs - Mozilla
On getting the property, the property is removed from the object and re-added, but implicitly as a data property this time.
Read more >Avoid getters and setters whenever possible
Noooo!!! Don't click that generate getters and setters option!!! I like the rule: "Don't use accessors and mutators." Like any good rule, ...
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
Yes, that’s exactly why I decided to remove
Database.global
. Here I just provide a workaround for you because you might want to use the global database like before.You can change the visibility of the setter, so that it can only be modified inside the kt file: