Hello... Regarding spring in kotlin, is there a wa...
# server
s
Hello... Regarding spring in kotlin, is there a way to create Cassandra tables other than the
@Table
annotation? Using a bean or overrides?
t
Maybe a database migration tool like Liquibase might be what your looking for?
s
I don't know about it, buy will see for sure, my issue is that tables aren't created by default when the server starts.. I'm still developing the app with Cassandra, but I can't move ahead because tables aren't created...
s
Thank you, will try this and hopefully it works... I'm not sure if I'm the only one who's facing this issue, but I could create any db table using annotations with kotlin, neither with jdbc nor with Cassandra
t
Well, be a bit careful with it to make sure you do not just override things, as this can lead to loss of data (database migration tooling is there for that purpose) but in this case ``CREATE_IF_NOT_EXISTS`` might be the setting you are looking for
s
i tried several settings in both `application.properties'`and in the
@Configuration
class... will learn on the migration tools
It worked by removing the
@Data
annotations from data classes, all tables were created!
t
@Data as in the lombok annotation?
s
yes
it was like this
Copy code
@Data
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PRIVATE, force = true)
@Table("ingredients")
data class Ingredients(
    @PrimaryKey
    val id: String,
    val name: String,
    val type: Type
)
now it is
Copy code
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PRIVATE, force = true)
@Table("ingredients")
data class Ingredients(
    @PrimaryKey
    val id: String,
    val name: String,
    val type: Type
)
thats it.
t
Thats quite weird. But on another note, kotlins
data class
that you use here already has getters, toString, equals, hashcode and a allargs constructor. So im not sure how the lombok annotations will work with that.
(Also, im not sure it can have a noargs constructor 🤔
s
i don't know... there is another developer i found on Github that is facing the same issue. just want to post the solution for her... also let me try by removing the other annotations and see... will update you
it worked without these annotations as well...
t
🙂 Yes, you also dont really need lombok with kotlin, most of the things lombok tries to do for java are already language features in kotlin 🙂 so I would experiment with removing lombok from your project all together
s
Got you...