Skip to main content

AccessType class gone away?

9 replies [Last post]
lucduponcheel
Offline
Joined: 2004-06-14

I downloaded the b37 nightly build today
I cannot even compile my code any more because the AccessType class seems to be gona away
(I'm using @Entity(acccess=FIELD))

maybe just a 'nightly build' issue?

gonna try the 'stable' b36 asap and see if AccessType is still in

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ss141213
Offline
Joined: 2005-03-30

> I also figured out that all the relevant classes and
> annotations now moved to other packages, so, if you
No, they have [b]not[/b] moved to a new package. javax.xml.bind.annotation.AccessType is a [b]JAXB[/b] API. It is not same as what used to be there in javax.persistence package.

> do NOT use the default, then the following should
> also work
>
> import javax.xml.bind.annotation.XmlAccessorType;
> import static
> javax.xml.bind.annotation.AccessType.FIELD;
>
> import javax.persistence.Entity;
>
>
> @Entity
> @XmlAccessorType(value=FIELD)

No, it won't work. As I told you in the new spec, it is just not required.

-- Sahoo

lucduponcheel
Offline
Joined: 2004-06-14

same problem with b36

help! ;-)

ss141213
Offline
Joined: 2005-03-30

The spec has changed and the APIs have changed because of changes in EJB 3 proposed final draft. In the new version user does [b]not[/b] have to use [b]access[/b] any more. Persistence provider [b]automatically[/b] figures out if your bean is annotating fields or methods by looking at the class definition. See the latest Entity.java file:

https://glassfish.dev.java.net/source/browse/glassfish/persistence-api/s...

So it is suffcient to say the following:

@Entity
public class Person {

@Id private String ssn;
}

or

@Entity public class Person {
private String ssn;
@Id public String getId(){return id;}
public void setId(String id) {this.id = id;}
}

Of course [i]it is an error if you annotate both fields and methods at the same time[/i]. Hope this helps,

Sahoo

lucduponcheel
Offline
Joined: 2004-06-14

thanks,

I also figured out that all the relevant classes and annotations now moved to other packages, so, if you do NOT use the default, then the following should also work

import javax.xml.bind.annotation.XmlAccessorType;
import static javax.xml.bind.annotation.AccessType.FIELD;

import javax.persistence.Entity;

@Entity
@XmlAccessorType(value=FIELD)

lucduponcheel
Offline
Joined: 2004-06-14

something else (related topic)

My entity had an embedded embeddable.
Lokks as if the embedded embeddable is not saved in the db any more.

(for the embeddable, I used both the 'default' accessType
and the explicitly defined one (see previous post) none of them worked)

ss141213
Offline
Joined: 2005-03-30

> something else (related topic)
>
> My entity had an embedded embeddable.
> Lokks as if the embedded embeddable is not saved in
> the db any more.
>
> (for the embeddable, I used both the 'default'
> accessType
> and the explicitly defined one (see previous post)
> none of them worked)

Please give example of what you are trying to do. Before that please try with the suggestions about AccessType I made in an earlier reply.

Thanks,
Sahoo

lucduponcheel
Offline
Joined: 2004-06-14

Sorry, but I can't help that

--- begin ---
import javax.xml.bind.annotation.XmlAccessorType;
import static javax.xml.bind.annotation.AccessType.FIELD;

import javax.persistence.Entity;

@Entity
@XmlAccessorType(value=FIELD)
---- end ----

just works (did it a few seconds ago)
[ of course, just -- @Entity -- works as well (thanks for that!) ]

could it not be the case that the persistency package
for its 'automatic acces', makes use of the javax.xml.bind.annotation package?

btw: javax.persistence.AccesType is no longer there!

As for the Embeddable/Embedded stuff: I'm doing the simplest kind of situation one can think of:

@Entity
class Container {
@Id private Integer id;
// other stuff
@Embedded private Containee c;
// rest of class
}

where

@Embeddable
class Containee {
private String name;
// rest of class
}

It did work up to b34, it does not with b37
(and 'automatic' AccessType (FIELD))

Gonna try b35 and b36
(a matter of changing a symbolic link :-) )

Cheers, Luc

ss141213
Offline
Joined: 2005-03-30

> Sorry, but I can't help that
>
> --- begin ---
> import javax.xml.bind.annotation.XmlAccessorType;
> import static
> javax.xml.bind.annotation.AccessType.FIELD;
>
> import javax.persistence.Entity;
>
> @Entity
> @XmlAccessorType(value=FIELD)
> ---- end ----
>
> just works (did it a few seconds ago)

That worked not because you have written @XmlAccessorType(value=FIELD). That would have worked even otherwise.

> [ of course, just -- @Entity -- works as well (thanks
> for that!) ]
>
> could it not be the case that the persistency
> package
> for its 'automatic acces', makes use of the
> javax.xml.bind.annotation package?
>

Noop, it does not work that way. Check out the spec.

> btw: javax.persistence.AccesType is no longer there!
>
You are right. The way the current spec is written, that class is not reqired any more. Access type is automatically determined by looking at the class definition.

> As for the Embeddable/Embedded stuff: I'm doing the
> simplest kind of situation one can think of:
>
> @Entity
> class Container {
> @Id private Integer id;
> // other stuff
> @Embedded private Containee c;
> // rest of class
> }
>
> where
>
> @Embeddable
> class Containee {
> private String name;
> // rest of class
> }
>
> It did work up to b34, it does not with b37

I don't see anything wrong with the code above.
Looks like a regression to me. [i]I am suspecting it to do with new discovery rules about access type of embeddable objects.[/i]
Would you mind filing a bug using http://glassfish.dev.java.net/issues/enter_bug.cgi Please also attach a test case, if you can.

Thanks,
Sahoo

lucduponcheel
Offline
Joined: 2004-06-14

ok
I have filed the bug and attached a zip file
(complete ant project) so that you can easily reproduce

glassfish
Issue 240