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

Cannot save classes that inherit from another with ids generic types #474

Closed
3 of 4 tasks
mkfuri opened this issue Apr 2, 2020 · 4 comments · Fixed by micronaut-projects/micronaut-core#4343
Closed
3 of 4 tasks
Labels
status: pr submitted A pull request has been submitted for the issue type: bug Something isn't working
Milestone

Comments

@mkfuri
Copy link

mkfuri commented Apr 2, 2020

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Create an abstract class with the primary key as Generic Type extends Serializable
  2. Create another class that extends the above abstract class
  3. Try to save it

Expected Behaviour

I expect that the concrete class will save in the DB (in my case is a MySql DB). With Micronaut Data 1.0.0 works fine

Actual Behaviour

When I try to save I have the following exception.

>io.micronaut.data.exceptions.DataAccessException: SQL Error executing INSERT: Conversion not supported for type java.io.Serializable
	at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.lambda$persistOne$9(DefaultJdbcRepositoryOperations.java:661)
	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)
	at io.micronaut.data.runtime.intercept.DefaultSaveEntityInterceptor.intercept(DefaultSaveEntityInterceptor.java:43)
	at io.micronaut.data.intercept.DataIntroductionAdvice.intercept(DataIntroductionAdvice.java:80)
	at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:69)
	at io.micronaut.validation.ValidatingInterceptor.intercept(ValidatingInterceptor.java:123)
	at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:69)
	at com.navent.finprop.crm.repositories.PetitionerCRMRepositorySpec.Test save methods(PetitionerCRMRepositorySpec.groovy:19)
Caused by: java.sql.SQLException: Conversion not supported for type java.io.Serializable
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:505)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:479)
	at com.mysql.cj.jdbc.result.ResultSetImpl.getObject(ResultSetImpl.java:1382)
	at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.getEntityId(DefaultJdbcRepositoryOperations.java:1118)
	at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.lambda$persistOne$9(DefaultJdbcRepositoryOperations.java:639)
	... 9 more

I have the following structures.

The abstract base class

public abstract class BaseEntity<ID extends Serializable> implements Serializable {

    @Id
    @GeneratedValue
    private ID id;
    @DateCreated
    private LocalDateTime createdDate;
    @DateUpdated
    private LocalDateTime updatedDate;
}

The concrete class

@Entity
public class Guarantee extends BaseEntity<Long> {

    @NotBlank
    @Size(max = 45)
    private String code;
    @NotNull
    private GuaranteeStatus status;
    private BigDecimal price;
}

Environment Information

  • Operating System: Ubuntu 18.04 LTS
  • Micronaut Version: mn 1.3.3 and mn-data 1.0.2
  • JDK Version:
    openjdk version "11.0.6" 2020-01-14
    OpenJDK Runtime Environment 18.9 (build 11.0.6+10)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.6+10, mixed mode)

Example Application

  • TODO: link to github repository with example that reproduces the issue
@graemerocher graemerocher added the type: bug Something isn't working label Apr 2, 2020
@graemerocher graemerocher added this to the 1.0.3 milestone Apr 2, 2020
@mkfuri
Copy link
Author

mkfuri commented Aug 29, 2020

Hi @graemerocher ! Do you have this bug in roadmap?
I try again with mn 1.3.6 and mn-data 1.1.3 and It doesn't work too

@graemerocher
Copy link
Contributor

Hope to get back to Micronaut Data bug fixing soon. PRs welcome in the meantime

@mkfuri
Copy link
Author

mkfuri commented Aug 29, 2020

@graemerocher I think that the problem is in the data-processor module. I tried to fix it but I don't understand how can I debug this module.
Do you have any tip?

@graemerocher
Copy link
Contributor

PR submitted upstream to Micronaut core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pr submitted A pull request has been submitted for the issue type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants