Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin Support #20

Open
paulkagiri opened this issue Sep 23, 2017 · 2 comments
Open

Kotlin Support #20

paulkagiri opened this issue Sep 23, 2017 · 2 comments

Comments

@paulkagiri
Copy link

paulkagiri commented Sep 23, 2017

I have been using norm and I would say I like the simplicity very much. Thanks for the great library.

Lately I tried using norm with kotlin but I did not manage to get the Id autogeneration to work. The Id field was also not marked as a primary key. Would you mind giving a full example in kotlin like the one you have given for java

Here is what I had:

@Table(name = "employees")
data class Employee(
        @Column(name = "number") val number: String,
        @Column(name = "name") var name: String,
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        var id: Long = -1) {

}

I also tried(but did not also work):

@Table(name = "employees")
data class Employee(
        @Column(name = "number") val number: String,
        @Column(name = "name") var name: String) {

    @Id
    @GeneratedValue
    public var id: Long = -1
}
@ccleve
Copy link
Member

ccleve commented Sep 23, 2017

What's not working? Is this a createTable() problem, or something else? Is there an error message?

@paulkagiri
Copy link
Author

Sorry for the late response. There is no error but it does not work as expected. Basically when you run db.createTable(Employee()) it does not mark the id as primary and when you run db.insert(employee) it does not autogenerate a value for the id.

If you have some time you can try to convert the java example and see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants