https://kotlinlang.org logo
#serialization
Title
# serialization
x

xun su

03/09/2023, 1:26 AM
Hi, I'm using quarkus and hibernate, here is a demo from the doc
Copy code
@Entity
public class Book extends PanacheEntity {

    public String title;

    @ManyToOne
    @JsonbTransient 
    public Author author;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Book)) {
            return false;
        }

        Book other = (Book) o;

        return Objects.equals(id, other.id);
    }

    @Override
    public int hashCode() {
        return 31;
    }
}
As you can see, here is annotation named
@JsonbTransient
, the docs says "We mark this property with
@JsonbTransient
to avoid infinite loops when serializing with JSON-B.", I wanna know the counterpart annotation in
kotlinx.serialization.Serializable
. I've tried
@transient
, but it seems to bring other hibernate initialize error.
a

Adam S

03/09/2023, 9:06 AM
What errors did you get? Can you share some Kotlin code to demonstrate what you tried? Are you using the correct
@Transient
annotation (don't confuse it with kotlin.jvm.Transient)?
6 Views