i know how to use room in android dev, but don’t know how to do in ktor, or say in server code
You can’t, since ROOM is an ORM targeted only towards Android and Sqlite.
You can choose any other Java ORM: Hibernate, JOOQ, eBean, OrmLite etc. I personally used eBean, it’s straightforward to use.
teacher, how sure are you? android is also based on linux, and app have a process, i think it may be ok if some work, but i have no idea.
whether have ORM focused on kotlin, not java?
It’s not about what the OS it’ s based upon, it’s about Room using Android-specific libraries that are not available in a standard JVM.
If you want a pure Kotlin ORM I’d recommend Exposed, the entity and repository mapping is a bit verbose but I’ve used it in some professional projects and it never failed me.
Or as andob said, you can pretty much use any Java ORM, though you will probably need to use the kotlin-allopen
plugin for a nice developer experience.
Historically, ORMs on the JVM uses JDBC to handle connections to databases.
Now, while the JDK inside Android supports JDBCs and SQLite can be used used with it (with some hacks), there are many compatibility issues with SQLite drivers (a driver is an implementation of the JDBC interface java.sql.Driver) on Android since Android JDK has been customized for the needs of a mobile device.
The Android team decided to reimplement from scratch access to SQLite, apart from JDBC (which indeed is a very old mechanism).
Room is very tied to internal mechanisms of the customizations of the Android runtime and it is not usable outside of it.
Other ORM solutions that I like very much are Exposed (from the JetBrains team) and Ktorm.
Both solutions uses JDBC drivers but Exposed is starting to add some conveniences for coroutines, which are very handful for Ktor.
It’s 4 years later, sorry for the bump.
Now with Room adding KMP support, I think this may be possible to do. It can run on Desktop (JVM), so it should be technically possible to use it on the server-side. IIRC, it probably also supports Kotlin/Native (on macOS and Linux, but usage is not documented last time I checked), so it can be used in conjunction with a Kotlin/Native Ktor server for minimal overhead and memory footprint.
Though I’m not sure about the performance/reliability guarantees that would provide (since it mainly targets client-side use-cases), and it’s tied to SQLite (which may be totally fine; there’s a recent movement in the JS world towards scalable SQLite).