简而言之,我的一个实体有一个GeometryCollection,当你调用"getBoundary"时会抛出一个异常(为什么这是另一本书,现在让我们说这就是它的工作方式).
有没有办法告诉杰克逊不要包括那个特定的吸气剂?我知道当我拥有/控制代码时我可以使用@JacksonIgnore.但事实并非如此,杰克逊通过连续序列化父对象来达到这一点.我在jackson文档中看到了一个过滤选项.这是一个看似合理的解决方案吗?
谢谢!
我已经完成了我的JPA事件(postUpdate),当我更新我的实体上的属性时,它们正在触发,除了映射为@ElementCollection的属性.
这是限制吗?配置选项?
这是我的实体的一部分
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Pckg {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(nullable = false, length = 100)
private String title;
@ElementCollection
@CollectionTable (
name = "PckDest",
joinColumns = @JoinColumn(name = "package_id", nullable = false)
)
@Column(name = "destination", nullable = false, length = 150)
private List<String> destinations;
...
Run Code Online (Sandbox Code Playgroud)
换句话说,如果我更改"标题",我的听众会收到更改,但是当我更改"目标"时不会发生相同的变化
我通过spring(3.1)使用JPA和hibernate(4.0)作为提供者
谢谢
我目前正在使用jackson 1.7尝试从第三方库反序列化对象.
所以我设置我的ObjectMapper来使用我的mixIn类,如下所示:
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.getDeserializationConfig().addMixInAnnotations(com.vividsolutions.jts.geom.Point.class, MixIn.class);
Run Code Online (Sandbox Code Playgroud)
我的MixIn类用@JsonCreator注释,并用逻辑实例化那里的Point对象
public class MixIn {
private static final GeometryFactory geometryFactory = GeometryFactoryFactory.getGeometryFactory();
@JsonCreator
public static Point createPoint(@JsonProperty("x")double x, @JsonProperty("y")double y) {
return geometryFactory.createPoint(new Coordinate(x, y));
}}
Run Code Online (Sandbox Code Playgroud)
但我得到了例外
No suitable constructor found for type [simple type, class com.vividsolutions.jts.geom.Point]: can not instantiate from JSON object (need to add/enable type information?)
Run Code Online (Sandbox Code Playgroud)
调试显示我的MixIn类永远不会被调用,我认为它需要是具体的类,但结果相同.
我究竟做错了什么?我的配置有什么问题?
谢谢