You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by kestas <ka...@gmail.com> on 2017/07/25 11:11:41 UTC

Do not store @javax.persistence.Transient fields

Is there a simple way to ensure fields marked as @javax.persistence.Transient
are not being stored in cache?



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Do-not-store-javax-persistence-Transient-fields-tp15604.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Do not store @javax.persistence.Transient fields

Posted by vkulichenko <va...@gmail.com>.
Ignite also honors the standard 'transient' keyword.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Do-not-store-javax-persistence-Transient-fields-tp15604p15640.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Do not store @javax.persistence.Transient fields

Posted by vkulichenko <va...@gmail.com>.
It's actually better to discuss this on dev list. However, I agree with
Nikolay, I doubt such patch can be accepted.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Do-not-store-javax-persistence-Transient-fields-tp15604p15924.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Do not store @javax.persistence.Transient fields

Posted by Nikolai Tikhonov <nt...@apache.org>.
I'm not sure that this patch can be included in Apache Ignite.
javax.persistence.Transient annotation part of external dependency
(Persistence Api ) Apache Ignite core doesn't have external dependencies
(except cache-api). You can build your own build which will include this
patch and used it.

On Mon, Jul 31, 2017 at 11:27 AM, kestas <ka...@gmail.com> wrote:

> Ok, so i digged deeper in the problem and will try to describe it
> We want to cache persistent objects and need cache to function exactly like
> it is a DB in respect of javax.persistence.Transient annotated fields. Some
> business logic is doing deep object cloning and it needs those
> javax.persistence.Transient to be copied also. So we can't mark them with
> transient keyword, nor use readResolve. We have huge domain with hundreds
> of
> classes, i've looked into implementing BinarySerializer but this adds huge
> amount of code which have to be maintained for each object having transient
> fields. Same applies to Binarylizable plus it would add compile dependency
> on Ignite which we want to keep as a pluggable option.
> However small patch to ignite library seemd to solve my problems:
> ---
> src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
> (revision )
> +++
> src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
> (revision )
> @@ -392,7 +392,7 @@
>      private static boolean serializeField(Field f) {
>          int mod = f.getModifiers();
>
> -        return !Modifier.isStatic(mod) && !Modifier.isTransient(mod);
> +        return !Modifier.isStatic(mod) && !Modifier.isTransient(mod) &&
> (f.getAnnotation(javax.persistence.Transient.class) == null);
>      }
>
> is there any chance Ignite can add  support for handling
> javax.persistence.Transient annotations?
>
>
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Do-not-store-javax-persistence-Transient-fields-
> tp15604p15811.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Re: Do not store @javax.persistence.Transient fields

Posted by kestas <ka...@gmail.com>.
Ok, so i digged deeper in the problem and will try to describe it
We want to cache persistent objects and need cache to function exactly like
it is a DB in respect of javax.persistence.Transient annotated fields. Some
business logic is doing deep object cloning and it needs those
javax.persistence.Transient to be copied also. So we can't mark them with
transient keyword, nor use readResolve. We have huge domain with hundreds of
classes, i've looked into implementing BinarySerializer but this adds huge
amount of code which have to be maintained for each object having transient
fields. Same applies to Binarylizable plus it would add compile dependency
on Ignite which we want to keep as a pluggable option.
However small patch to ignite library seemd to solve my problems:
---
src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
(revision )
+++
src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
(revision )
@@ -392,7 +392,7 @@
     private static boolean serializeField(Field f) {
         int mod = f.getModifiers();
 
-        return !Modifier.isStatic(mod) && !Modifier.isTransient(mod);
+        return !Modifier.isStatic(mod) && !Modifier.isTransient(mod) &&
(f.getAnnotation(javax.persistence.Transient.class) == null);
     }

is there any chance Ignite can add  support for handling
javax.persistence.Transient annotations?





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Do-not-store-javax-persistence-Transient-fields-tp15604p15811.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Do not store @javax.persistence.Transient fields

Posted by vkulichenko <va...@gmail.com>.
This exception is optional and does not affect anything.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Do-not-store-javax-persistence-Transient-fields-tp15604p15704.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Do not store @javax.persistence.Transient fields

Posted by kestas <ka...@gmail.com>.
We do not want to have dependency on Ignite in our domain subsystem so
implementing Binarylizable is not an option (at the moment). Reading
documentation i found Ignite honors readResolve and writeReplace methods
which should work for my case. However in Ignite documentation says
readResolve is defined as follows: ANY-ACCESS-MODIFIER Object readResolve().
and java 8 doc says
ANY-ACCESS-MODIFIER Object readResolve() throws ObjectStreamException;

the difference is in throws declaration. Does it makes difference to Ignite
is there a throw clause or not?



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Do-not-store-javax-persistence-Transient-fields-tp15604p15681.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Do not store @javax.persistence.Transient fields

Posted by Nikolai Tikhonov <nt...@apache.org>.
Apache Ignite does not handle this annatation. You can implement
org.apache.ignite.binary.Binarylizable interface. It allows to implement
custom serialization logic for binary objects.

On Tue, Jul 25, 2017 at 2:11 PM, kestas <ka...@gmail.com> wrote:

> Is there a simple way to ensure fields marked as
> @javax.persistence.Transient
> are not being stored in cache?
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Do-not-store-javax-persistence-
> Transient-fields-tp15604.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>