Transient annotation in gas

127 views
Skip to first unread message

lindee

unread,
Mar 16, 2012, 6:20:12 PM3/16/12
to gran...@googlegroups.com
if an entity property is marked @Transient shouldn't the generated as3 property be marked [Transient] as well?

i noticed the problem when my transient properties were causing meta_dirty to change... not sure if this behavior is expected.

i ended up just adding a line in the template before the getter generation:

if (jProperty.isAnnotationPresent(Transient.class))
         {%>
[Transient]<%}%>

Franck Wolff

unread,
Mar 26, 2012, 2:33:02 PM3/26/12
to Granite Data Services Forum
There are 3 different types of "transient" properties:

1) the Java keyword (public transient String myVar): the field won't
be serialized (java.io.Serializable).
2) the persistence annotation (@Transient public String myVar): the
field won't be persisted in a database (JPA).
3) the Flex annotation ([Transient] public var myVar:String): the
field won't be serialized (AMF3 serialization).

If you use the Java keyword, GraniteDS won't generate the field and
its value will be ignored at serialization time.
If you use the JPA annotation, GraniteDS will generate the field and
its value will be serialized.
If you use the Flex annotation, Flex won't serialize your field.

Consider this data flow: Flex App <-(a)-> Java App <-(b)-> Database

@Transient controls (b), the Java keyword and the Flex annotation
control (a).

It is perfectly legal and normal to serialize (a) a value between your
Flex and Java applications, while this value isn't persisted in a
database.

Dahn Maier

unread,
Mar 27, 2012, 11:57:16 AM3/27/12
to gran...@googlegroups.com
This is beautifully clear and concise. Thanks Frank.
Dahn

Franck Wolff

unread,
Mar 27, 2012, 12:20:28 PM3/27/12
to Granite Data Services Forum
I should have added that annotating a property with the [Transient]
annotation wouldn't change anything to the serialization process when
it comes to GraniteDS' generated AS3 classes: the serialization is
controlled by the readExternal/writeExternal methods and they do not
check for [Transient] properties.

Maxim Kopeyka

unread,
Mar 5, 2015, 8:06:03 AM3/5/15
to gran...@googlegroups.com
I'm trying to use Lazy collections on server side but I have no plans to implement Lazy on Flex side.
So, I can't use this annotation because JPA will ignore projects collection
@javax.persistence.Transient;

I've tried another annotation but Granite ignores it and I see exception could not initialize proxy - no Session
@java.beans.Transient(true)
 
I've tried to use transient for projects field, Granite still have a problem with Lazy collection
private transient List<Project> projects;

How to solve this problem?

    @ManyToMany(fetch = FetchType.LAZY)
    @ListIndexBase(0)
    @OrderColumn(name="rank", nullable=false)
    @JoinTable(name="table1",
                indexes = {@Index(name="idx_1", columnList = "ch_id")},
                joinColumns={@JoinColumn(name="ch_id")},
                inverseJoinColumns={@JoinColumn(name="p_id")}
    )
    public List<Project> getProjects() {
        return projects;
    }
 
Reply all
Reply to author
Forward
0 new messages