![]() Hibernate: alter table Person add constraint UK_is4vd0f6kw9sw4dxyie5cy9fa unique (name) Here is the resulting SQL, coming from the logs: Hibernate: create table Person (id integer, name varchar(255) not null, primary key (id)) ![]() The reason for this is that to create to set that unique constraint, hibernate first creates the table, and THEN only alters it to add the constraint. The piece of code above will save three different entries, each with an identical name, and different ids. In short, you probably have to use the jpa, noarg and / or allopen gradle plugins for various reasons described here better than I would.ĩ0% of the magic fits in those couple lines to be added in your : plugins Setting unique constraints on an entity is not enough with SQLite I won't spend time on those here, you can get past them directly by cloning the sample and running it. Some issues and integration challenges between Kotlin and Hibernate are rather well documented. You can find a sample project applying the tips I'm describing over here. Kotlin, Hibernate and SQLite doesn't seem to be a very present combination online as of now. Maybe they're useful for someone else too :). ![]() This blog exposes some of the things I've found out while implementing my project. And because I wanted to learn a bit more about the Java Persistence API while staying minimal and local, I've decided to go for some good old hibernate and a SQLite setup. However, I've already written a bit about why I don't quite like it personally (It has a lot to do with code duplication). When you need some kind of SQL database interaction in Kotlin, exposed seems to be pretty much the norm. It's barely more than a personal note taking app.Īnd for once, I wanted to build a native application instead of a webapp. ![]() ![]() Last month, with Compose Multiplatform going 1.0, I've been wanting to build a simple application for myself. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |