Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PanacheEntity do not set schema to sequence from @Table schema #44553

Open
rodrigopim opened this issue Nov 17, 2024 · 4 comments
Open

PanacheEntity do not set schema to sequence from @Table schema #44553

rodrigopim opened this issue Nov 17, 2024 · 4 comments
Labels
area/panache kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.

Comments

@rodrigopim
Copy link

Describe the bug

Creating tables and sequences in another schema and using PanachEntity as an ID generation strategy, always seeks sequence in the default database schema.

Caused by: org.hibernate.exception.SQLGrammarException: error executing SQL statement [ERROR: relation "test_seq" does not exist (42P01)] [select nextval('TEST_SEQ')]

To be able to use the sequence in another schema, I have to use PanacheEntityBase and set manually.

@SequenceGenerator(name = "test_id_generator", schema = "MYSCHEMA", sequenceName = "test_seq")

It can take from @table annotation.

@Table(name = "MYTABLE", schema = "MYSHCEMA")

Expected behavior

Sequences have the same scheme defined in @table

Actual behavior

Sequence always looks for the standard scheme

How to Reproduce?

  1. Implement a class model extending PanacheEntity, defining the scheme created with script for the table
  2. Create your database using Flyway or Script executed on the database client in the specific scheme.
  3. Try to execute Quarkus and create a record in this table.

Output of uname -a or ver

Linux 6.11.6-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 16:09:34 UTC 2024 x86_64 GNU/Linux

Output of java -version

openjdk version "21.0.5" 2024-10-15 OpenJDK Runtime Environment (Red_Hat-21.0.5.0.11-1) (build 21.0.5+11) OpenJDK 64-Bit Server VM (Red_Hat-21.0.5.0.11-1) (build 21.0.5+11, mixed mode, sharing)

Quarkus version or git rev

<quarkus.platform.version>3.15.1</quarkus.platform.version>⏎

Build tool (ie. output of mvnw --version or gradlew --version)

CLI - 3.16.3

Additional information

No response

@rodrigopim rodrigopim added the kind/bug Something isn't working label Nov 17, 2024
Copy link

quarkus-bot bot commented Nov 17, 2024

/cc @FroMage (panache), @loicmathieu (panache)

@FroMage
Copy link
Member

FroMage commented Nov 18, 2024

So, if I understand correctly, you'd like for id sequence generators to use the same schema as the table, unless specified explicitly?

If I get Panache out of the equation, that'd be:

@MappedSuperClass
public class Top {
 @Id
 @GeneratedValue
 public Long id;
}

@Table(schema = "other")
@Entity
public class Entity extends Top {
 // here, implicitely, id generator should be in "other" schema
}

@FroMage FroMage added the triage/needs-feedback We are waiting for feedback. label Nov 18, 2024
@rodrigopim
Copy link
Author

So, if I understand correctly, you'd like for id sequence generators to use the same schema as the table, unless specified explicitly?

If I get Panache out of the equation, that'd be:

@MappedSuperClass
public class Top {
@id
@GeneratedValue
public Long id;
}

@table(schema = "other")
@entity
public class Entity extends Top {
// here, implicitely, id generator should be in "other" schema
}

Thanks for the return. Yes, I think this should be the behavior when using implicit ID.

@FroMage
Copy link
Member

FroMage commented Nov 19, 2024

@gavinking WDYT of this ask? Something that makes sense in Hibernate itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/panache kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.
Projects
None yet
Development

No branches or pull requests

2 participants