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

SemanticError when editing an entity #51

Open
nystromb opened this issue Feb 25, 2025 · 0 comments
Open

SemanticError when editing an entity #51

nystromb opened this issue Feb 25, 2025 · 0 comments

Comments

@nystromb
Copy link

nystromb commented Feb 25, 2025

First off, very nice project! Its what I need for a small project. It seems to work very well except with one issue.

Describe the bug
I have a project with a single entity that contains a UUID id field, but when I modify a field on that record, and click save the record does not update.

Is the bug at startup before you perform any action?
No

Stacktrace

2025-02-24T19:38:09.935-06:00 DEBUG 18100 --- [backend] [nio-8080-exec-6] org.hibernate.SQL                        : select s1_0.id,s1_0.category,s1_0.context,s1_0.text from soundbite s1_0 where s1_0.id=?
Hibernate: select s1_0.id,s1_0.category,s1_0.context,s1_0.text from soundbite s1_0 where s1_0.id=?
2025-02-24T19:38:09.956-06:00 DEBUG 18100 --- [backend] [nio-8080-exec-6] o.s.web.servlet.DispatcherServlet        : Failed to complete request: org.hibernate.query.SemanticException: Cannot compare left expression of type 'java.util.UUID' with right expression of type 'java.lang.String'
2025-02-24T19:38:09.958-06:00 ERROR 18100 --- [backend] [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.hibernate.query.SemanticException: Cannot compare left expression of type 'java.util.UUID' with right expression of type 'java.lang.String'] with root cause

org.hibernate.query.SemanticException: Cannot compare left expression of type 'java.util.UUID' with right expression of type 'java.lang.String'
	at org.hibernate.query.sqm.internal.TypecheckUtil.assertComparable(TypecheckUtil.java:406) ~[hibernate-core-6.6.2.Final.jar:6.6.2.Final]
	at org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate.<init>(SqmComparisonPredicate.java:46) ~[hibernate-core-6.6.2.Final.jar:6.6.2.Final]
	at org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate.<init>(SqmComparisonPredicate.java:32) ~[hibernate-core-6.6.2.Final.jar:6.6.2.Final]
	at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.equal(SqmCriteriaNodeBuilder.java:2169) ~[hibernate-core-6.6.2.Final.jar:6.6.2.Final]
	at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.equal(SqmCriteriaNodeBuilder.java:192) ~[hibernate-core-6.6.2.Final.jar:6.6.2.Final]
	at tech.ailef.snapadmin.external.dbmapping.CustomJpaRepository.update(CustomJpaRepository.java:157) ~[snap-admin-0.2.1.jar:0.2.1]
	at tech.ailef.snapadmin.external.dbmapping.SnapAdminRepository.update(SnapAdminRepository.java:191) ~[snap-admin-0.2.1.jar:0.2.1]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]

@entity code

@Entity
@Table(name = "soundbite")
public class Soundbite {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    private UUID id;

    @Column
    private String context;

    @Column
    private String text;

    @Column
    private String category;

  // getters and setters
  ...
}

application.properties
I dont think the properties file is related

Additional context

From what I can tell, it tries to do a SELECT call before editing the entity, and it seems to use the id as a string to pull in the where statement. Not sure if this sounds right. Does my configuration seem correct or is there a bug here?

Spring 6.2
PostgresQL 16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant