-
Notifications
You must be signed in to change notification settings - Fork 52
Micronaut SQL JPA requires Micronaut Data Model dependency #1157
Copy link
Copy link
Open
micronaut-projects/micronaut-gradle-plugin
#869Labels
type: bugSomething isn't workingSomething isn't working
Description
I expected the following dependencies to be enough:
implementation("io.micronaut.data:micronaut-data-tx-hibernate")
implementation("io.micronaut.sql:micronaut-hibernate-jpa")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
runtimeOnly("com.h2database:h2")but without:
implementation("io.micronaut.data:micronaut-data-model")We don't mention in the docs micronaut-data-model is necessary.
Without it, I get:
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoClassDefFoundError: io/micronaut/data/annotation/GeneratedValue$Type [in thread "Test worker"]
This is the domain of the sample app:
package example.micronaut.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.micronaut.serde.annotation.Serdeable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import java.util.HashSet;
import java.util.Set;
import static jakarta.persistence.GenerationType.AUTO;
@Serdeable
@Entity
@Table(name = "genre")
public class Genre {
@Id
@GeneratedValue(strategy = AUTO)
private Long id;
@NotNull
@Column(name = "name", nullable = false, unique = true)
private String name;
@JsonIgnore
@OneToMany(mappedBy = "genre")
private Set<Book> books = new HashSet<>();
public Genre() {}
public Genre(@NotNull String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Book> getBooks() {
return books;
}
public void setBooks(Set<Book> books) {
this.books = books;
}
@Override
public String toString() {
return "Genre{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}Steps to reproduce:
clone https://github.com/grails-core-issues-forks/micronaut-sql-1157
cd ../micronaut-jpa-hibernate-gradle-java
./gradlew test
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: bugSomething isn't workingSomething isn't working