mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Scalar type querybeans generics error (#2082)
* Add failing test case for generic querybeans Types with generics arguments have not been processed correctly, they will lose their generics. This is not critical in Java, as the language has to be backwards compatible with Java 1.4, but will still become highlighted as a warning in all common IDEs. In Kotlin however, it's not a warning but a compile error. * Fix problem with generics in scalar type arg This fixes the issue introduced with ScalarType aware querybeans.
This commit is contained in:
1 parent
ee73fd47d5
commit
bcc8040afe
27 files changed
+427
-143
No files matched your search
@@ -5,6 +5,9 @@ import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.example.domain.otherpackage.GenericType;
|
||||
import org.example.domain.otherpackage.GenericTypeArgument;
|
||||
|
||||
/**
|
||||
* Address entity bean.
|
||||
*/
|
||||
@@ -24,8 +27,10 @@ public class Address extends BaseModel {
|
||||
@ManyToOne
|
||||
Country country;
|
||||
|
||||
GenericType<GenericTypeArgument> metadata;
|
||||
|
||||
/**
|
||||
* Create a copy of the address. Used to provide a 'snapshot' of
|
||||
* Create a copy of the address. Used to provide a 'snapshot' of
|
||||
* the shippingAddress for a give order.
|
||||
*/
|
||||
public Address createCopy() {
|
||||
@@ -36,7 +41,7 @@ public class Address extends BaseModel {
|
||||
copy.setCountry(country);
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return id + " " + line1 + " " + line2 + " " + city + " " + country;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.example.domain.otherpackage;
|
||||
|
||||
public class GenericType<T> {
|
||||
private T data;
|
||||
|
||||
public GenericType(final T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(final T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.example.domain.otherpackage;
|
||||
|
||||
public enum GenericTypeArgument {
|
||||
FOO,
|
||||
BAR;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package org.example.domain.otherpackage;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
public class GenericTypeAttributeConverter implements AttributeConverter<GenericType<GenericTypeArgument>, String> {
|
||||
@Override
|
||||
public String convertToDatabaseColumn(final GenericType<GenericTypeArgument> attribute) {
|
||||
return attribute.getData().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericType<GenericTypeArgument> convertToEntityAttribute(final String dbData) {
|
||||
return new GenericType<>(GenericTypeArgument.valueOf(dbData));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user