I'm using 2.1. I figure out that the problem is not on Property<Map>, but on Map<DateTimeInterval2, V> ser/deserialization. I have to define com.fasterxml.jackson.databind.KeyDeserializer when I'm using Jackson. Thanks a lot.
------------------ ???????? ------------------ ??????: "Niclas Hedhman";<[email protected]>; ????????: 2016??4??15??(??????) ????7:27 ??????: "dev"<[email protected]>; ????: Re: generic property? value composite as map keys? I think it should be viewed as a bug. Could you open a Jira ticket, and attach a small testcase? That would help a lot. Is this using 2.1 or 'develop' branch? If it is for 'develop', then there is a lot of internal changes going on regarding the serialization (testcase still helps) and it will be sorted out. If it is 2.1, I think it is serious enough to warrant a new release. Thanks a lot for reporting/finding this. Niclas On Fri, Apr 15, 2016 at 12:55 AM, zhuangmz08 <[email protected]> wrote: > 1. Maybe I should remove generic Property types. > 2. I mean, when I serialize TestEntity into EntityStore, it seems to be > ok. But when I deserialize it from EntityStore, map2 return expected values > but map1 throw [org.qi4j.spi.entitystore.EntityStoreException: > org.qi4j.api.value.ValueSerializationException: Could not serialize value]. > > > > > ------------------ ???????? ------------------ > ??????: "Niclas Hedhman";<[email protected]>; > ????????: 2016??4??15??(??????) ????0:49 > ??????: "dev"<[email protected]>; > > ????: Re: generic property? value composite as map keys? > > > > 1. No, you can't use generics in Property types. The reason is quite deep, > related to the way we build the internal model of the Mixins and their > State, which (at least at the moment) doesn't allow WildCardTyped classes. > I am not totally sure if it is possible to fix this, but there is no plans > to look into it. > > 2. Yes, that should be no problem. ValueComposites obeys equals() and > hashCode() from its immutable state, i.e. Property and Association values. > When you say "fail", what do you mean? > > > > On Fri, Apr 15, 2016 at 12:32 AM, zhuangmz08 <[email protected]> wrote: > > > Hi, I would like to ask two questions, any help will be appreciated. > > > > > > 1. Can I use generic type in Property? > > DateTimeInterval1 fails while DateTimeInterval2 is ok in the following > > snippet. > > ===========SNIPPET 1=========== > > public interface ITimeInterval<T> { > > Property<T> start(); > > Property<T> end(); > > } > > public interface DateTimeInterval1 extends ITimeInterval<LocalDate>, > > ValueComposite { // fail > > } > > > > > > public interface DateTimeInterval2 extends ValueComposite { // ok > > Property<LocalDate> start(); > > Property<LocalDate> end(); > > } > > ===========SNIPPET 1=========== > > > > > > 2. Can I use ValueComposite as map keys? > > map1 fails while map2 is ok in the following snippet. > > ===========SNIPPET 2=========== > > public interface TestEntity extends EntityComposite { > > Property<Map<DateTimeInterval2, String>> map1(); // fail > > Property<Map<String, DateTimeInterval2>> map2(); // ok > > } > > ===========SNIPPET 2=========== > > > > > -- > Niclas Hedhman, Software Developer > http://zest.apache.org - New Energy for Java > -- Niclas Hedhman, Software Developer http://zest.apache.org - New Energy for Java
