Skip to content

Migration to hibernate-reactive 2 - Problem with Sequence on non-id column #33932

Answered by Froidoh
Froidoh asked this question in Q&A
Discussion options

You must be logged in to vote

My solution:

public class CustomerIdGenerator extends MutinyGenerator {

    @Override
    public Uni<Object> generate(Mutiny.Session session, Object owner, Object currentValue, EventType eventType) {
        return session
                .createNativeQuery("select SEQ_CUSTOMER_ID.nextval FROM dual")
                .getSingleResult()
                .map(x -> BigInteger.valueOf((Integer) x))
                ;
    }
}
public class Customer extends PanacheEntityBase {

    @ValueGenerationType(generatedBy = CustomerIdGenerator.class)
    @Retention(RetentionPolicy.RUNTIME)
    public @interface CustomerId {}

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Froidoh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area/persistence OBSOLETE, DO NOT USE area/hibernate-reactive Hibernate Reactive
1 participant