You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public record Point (int x, int y) {
public static Point valueOf(String text) {
return null;
}
}
And most often store it using converter:
@WritingConverter
public class PointToStringConveter implements
Converter<Point, String>{
@Override
public String convert(Point point) {
return point.toString();
}
}
However for one entity we would like to store it as embedded object:
@Embedded(onEmpty = OnEmpty.USE_NULL)
private Point location;
Unfortunately in this case we receive the following exception while saving it:
Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.data.relational.core.mapping.RelationalPersistentEntity.getPropertyAccessor(Object)" because "persistentEntity" is null
at org.springframework.data.jdbc.core.convert.SqlParametersFactory.getParameterSource(SqlParametersFactory.java:244)
at org.springframework.data.jdbc.core.convert.SqlParametersFactory.lambda$getParameterSource$2(SqlParametersFactory.java:260)
at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:298)
at org.springframework.data.mapping.PersistentEntity.doWithAll(PersistentEntity.java:297)
at org.springframework.data.jdbc.core.convert.SqlParametersFactory.getParameterSource(SqlParametersFactory.java:247)
at org.springframework.data.jdbc.core.convert.SqlParametersFactory.forInsert(SqlParametersFactory.java:83)
at org.springframework.data.jdbc.core.convert.DefaultDataAccessStrategy.insert(DefaultDataAccessStrategy.java:104)
at org.springframework.data.jdbc.core.JdbcAggregateChangeExecutionContext.executeInsertRoot(JdbcAggregateChangeExecutionContext.java:83)
at org.springframework.data.jdbc.core.AggregateChangeExecutor.execute(AggregateChangeExecutor.java:85)
Spring Data JDBC: 3.1.0
The text was updated successfully, but these errors were encountered:
Can you please mention in the documentation that entity used in the converter can't be applied as embedded?
Because the raised exception is confusing and doesn't explain the cause of this issue.
Hi
We have the following Java record:
And most often store it using converter:
However for one entity we would like to store it as embedded object:
Unfortunately in this case we receive the following exception while saving it:
Spring Data JDBC: 3.1.0
The text was updated successfully, but these errors were encountered: