Micronaut Data JDBC does not support non-Long Generated ID types
See original GitHub issueWhen using Micronaut Data JDBC, using Id types that are not Long
will yield an error.
Steps to Reproduce
1. DDL:
create table if not exists example
(
id uuid DEFAULT uuid_generate_v1() PRIMARY KEY,
name text not null unique,
for_date timestamptz not null,
created_at timestamp default current_timestamp not null,
notes text
);
2. Entity:
@MappedEntity
public class Example {
@Id
@GeneratedValue
private String id;
private String name;
Date forDate;
@DateCreated
Date createdAt;
///... removed constructors getters and setters for brevity
}
3. Repository
@JdbcRepository(dialect = Dialect.POSTGRES)
public interface ExampleRepository extends CrudRepository<Example, String> {
Example find(String name);
}
4. Query:
Example example = new Example("Foo", new Date());
exampleRepository.save(example);
Expected Behaviour
Data should be saved without any errors
Actual Behaviour
Exception is thrown:
io.micronaut.data.exceptions.DataAccessException: SQL Error executing INSERT: Bad value for type long : 9c401364-5a01-11ea-803a-0242ac320500
at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.lambda$persistOne$9(DefaultJdbcRepositoryOperations.java:660)
at io.micronaut.transaction.support.AbstractSynchronousTransactionManager.executeWrite(AbstractSynchronousTransactionManager.java:177)
at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.persistOne(DefaultJdbcRepositoryOperations.java:612)
at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.persist(DefaultJdbcRepositoryOperations.java:602)
Environment Information
- Operating System: MacOS
- Micronaut Version: 1.3.2
- JDK Version: java version 11.0.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Micronaut Data - GitHub Pages
Since Micronaut Data is a build time tool, it will not work correctly unless ... no methods but defines the entity type and...
Read more >Access a database with Micronaut Data ... - Micronaut Guides
GenericRepository. A root interface that features no methods but defines the entity type and ID type as generic arguments.
Read more >Is there a way to export the DDL to a file with Micronaut Data ...
Micronaut Data JDBC comes with just a basic schema generator, you cannot enable the file export, but you can enable the query logging:...
Read more >Implement Database Queries and Build a Micronaut Application
Create Micronaut Data entities that map to Oracle Database tables ... public class Owner { // The ID of the class uses a...
Read more >JPA Data Access with Micronaut Data - Piotr's TechBlog
Currently, Micronaut Predator provides runtime support for JPA (Hibernate) and SQL (JDBC). Some other implementations are planned in the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To make it more efficient it would probably be better to do something like:
Please go ahead