You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by DanieleBosetti <D....@cmcmarkets.com> on 2018/10/11 09:31:36 UTC
Using annotations to remap fields when deserializing BinaryObjects
Hi,
is it possible to deserialize cache entries to Java objects, and specify
field names mapping using annotations?
In example, let's say cache entries follow a "with-dashes" naming
convention:
binaryObject.toString() = "domain.User[id=... idHash=... user-name=Paul ]"
And I deserialize it with
User user = binaryObject.deserialize();
class User {
*@MapToFieldName{"user-name"}*
private String name;
}
What can we put in place of "MapToFieldName" so that the "user-name" value
from the binary object is placed into the "name" field?
(I know the @QuerySqlField annotation, but that maps sql field names to
cache field names)
thanks!
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
RE: Using annotations to remap fields when deserializing
BinaryObjects
Posted by DanieleBosetti <D....@cmcmarkets.com>.
Hi,
Well one (weak) reason is that somebody else could already have put data to
a cache using the "dash" convention, and in that case we are unable to
retrieve this data (eg. how can we (automatically) deserialize the
"user-name" field?)
also, allowing this mapping would be in line with hibernate/jpa
(java.persistence.Column annotation); where you can have whatever naming
convention for database tables, and can then freely map to client pojos (DB
data comes first, client pojo-s come later).
anyway; what you say makes perfectly sense so, thanks for clarifying this!
(and we'll go with the single name convention).
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
RE: Using annotations to remap fields when deserializing
BinaryObjects
Posted by Stanislav Lukyanov <st...@gmail.com>.
Hi,
Nope, it doesn’t work like that.
Names of fields in the Java class are always the same as the names of the fields in BinaryObject.
Frankly, I don’t really see a strong use case for the customization you’re asking for.
If it is just to support different naming conventions in different places (Java, SQL, other clients)
then I’d much more preferred the simplicity to flexibility and forced a single naming across all context.
Stan
From: DanieleBosetti
Sent: 11 октября 2018 г. 12:31
To: user@ignite.apache.org
Subject: Using annotations to remap fields when deserializing BinaryObjects
Hi,
is it possible to deserialize cache entries to Java objects, and specify
field names mapping using annotations?
In example, let's say cache entries follow a "with-dashes" naming
convention:
binaryObject.toString() = "domain.User[id=... idHash=... user-name=Paul ]"
And I deserialize it with
User user = binaryObject.deserialize();
class User {
*@MapToFieldName{"user-name"}*
private String name;
}
What can we put in place of "MapToFieldName" so that the "user-name" value
from the binary object is placed into the "name" field?
(I know the @QuerySqlField annotation, but that maps sql field names to
cache field names)
thanks!
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/