You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Werner Punz <we...@gmail.com> on 2008/01/22 09:56:43 UTC
Weird problem/bug
Hi I tried to move a project over to openjpa yesterday
I get the message that my entities mix annotations on properties
and methods.
The main problem is, that
I have all my annotations set on the properties themselves
but I have a @PrePersist annotation set on a trigger method
which does some prepersist application logic!
All other annotations are directly on the instance variables
which define the properties! No other one is on any method!
JPA and Hibernate Annotations takes my entities as given and do not
choke on them, OpenJPA does.
This seems like a bug to me, am I right?
Version of openjpa, current stable version!
Werner
Re: Weird problem/bug
Posted by Werner Punz <we...@gmail.com>.
Patrick Linskey schrieb:
> FYI, I just checked in a change that should help with debugging of
> these sorts of issues in the future.
>
Ok I finally had time to test it, it was indeed the transient annotation
being present at the methods.
Thanks a lot for the help of anybody.
One last word, I moved over a small site with about 20-30 tables
from the JPA-RI (currently on 2.1.17) to OpenJPA1.1
from what I could gather, the JPA RI was about twice as fast as hibernate.
OpenJPA is about twice as fast subjectively as the JPA RI!
This is excellent stuff!
also from what I could gather, Hibernate choked on my in my application
by losing the entity reference in the entity manager, while the JPA RI
and OpenJPA worked fine!
Re: Weird problem/bug
Posted by Patrick Linskey <pl...@gmail.com>.
FYI, I just checked in a change that should help with debugging of
these sorts of issues in the future.
-Patrick
On Jan 23, 2008 2:15 AM, Werner Punz <we...@gmail.com> wrote:
> Prashant Bhat schrieb:
> > Just a guess! May be you need to remove @Transient here:-) as anyway you're
> > defining the annotation on properties.
> >
> > Regards,
> > Prashant
>
>
> That sounds reasonable, I will give it a try tonight.
>
> Cheers
>
> Werner
>
>
--
Patrick Linskey
202 669 5907
Re: Weird problem/bug
Posted by Werner Punz <we...@gmail.com>.
Prashant Bhat schrieb:
> Just a guess! May be you need to remove @Transient here:-) as anyway you're
> defining the annotation on properties.
>
> Regards,
> Prashant
That sounds reasonable, I will give it a try tonight.
Cheers
Werner
Re: Weird problem/bug
Posted by Prashant Bhat <pr...@gmail.com>.
Just a guess! May be you need to remove @Transient here:-) as anyway you're
defining the annotation on properties.
Regards,
Prashant
On Jan 23, 2008 5:53 PM, Werner Punz <we...@gmail.com> wrote:
>
> @Transient
> @PreUpdate
> public void preupdate() {
> prepersist();
> }
>
Re: Weird problem/bug
Posted by Werner Punz <we...@gmail.com>.
Patrick Linskey schrieb:
> Hi,
>
> Can you post the domain model that's causing the problems? Does the
> superclass use the same access type as the subclasses?
>
ok here is an example of a class which gets this error
@Entity
public class Session implements BaseEntity {
public static final int SESS_STATE_PREREGISTERED = 0;
public static final int SESS_STATE_APPROVED = 1;
public static final int SESS_STATE_REJECTED = 2;
@Transient
private Map<String,SessionMessages> messages;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "session")
Set<SessionMessages> sessionmessages = new HashSet<SessionMessages>();
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
String conferenceabbr = null;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ManyToOne(optional = true)
@JoinColumn(name = "SESSIONGROUP_UID", nullable = true)
SessionGroup sessiongroup;
private Integer sessionstate = SESS_STATE_PREREGISTERED;
@ManyToMany(mappedBy = "speakersessions", fetch = FetchType.LAZY,
cascade = CascadeType.PERSIST)
private Set<SpeakerData> speakers = new HashSet<SpeakerData>();
@Temporal(TemporalType.DATE)
private Date day;
@Temporal(TemporalType.TIME)
private Date starttime;
@Temporal(TemporalType.TIME)
private Date endtime;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Room room;
private Long orderattr;
public Set<SpeakerData> getSpeakers() {
return speakers;
}
public void setSpeakers(Set<SpeakerData> speakers) {
this.speakers = speakers;
}
public SessionGroup getSessiongroup() {
return sessiongroup;
}
public void setSessiongroup(SessionGroup sessiongroup) {
this.sessiongroup = sessiongroup;
}
public Date getDay() {
return day;
}
public void setDay(Date day) {
this.day = day;
}
public Date getStarttime() {
return starttime;
}
public void setStarttime(Date starttime) {
this.starttime = starttime;
}
public Date getEndtime() {
return endtime;
}
public void setEndtime(Date endtime) {
this.endtime = endtime;
}
public Integer getSessionstate() {
return sessionstate;
}
public void setSessionstate(Integer sessionstate) {
this.sessionstate = sessionstate;
}
public Room getRoom() {
return room;
}
public void setRoom(Room room) {
this.room = room;
}
public Long getOrderattr() {
return orderattr;
}
public void setOrderattr(Long orderattr) {
this.orderattr = orderattr;
}
public String getConferenceabbr() {
return conferenceabbr;
}
public void setConferenceabbr(String conferenceabbr) {
this.conferenceabbr = conferenceabbr;
}
public Map<String, SessionMessages> getMessages() {
if (messages == null ) {
Map<String, SessionMessages> mmap = new HashMap();
if (getId() != null) {
Collection<SessionMessages> messages =
getSessionmessages();
Iterator<SessionMessages> miter = messages.iterator();
while(miter.hasNext()) {
SessionMessages message = miter.next();
mmap.put(message.getLanguage().getLangID(),message);
}
}
//create missing messages
LanguageBean languageBean = (LanguageBean)
ConferenceUtil.getManagedBean("language");
Iterator<Language> langiter =
languageBean.getLanguages().iterator();
while(langiter.hasNext()) {
Language currentlang = langiter.next();
if (mmap.get(currentlang.getLangID()) == null) {
SessionMessages message = new SessionMessages();
message.setLanguage(currentlang);
message.setSession(this);
mmap.put(currentlang.getLangID(),message);
}
}
setMessages(mmap);
}
return messages;
}
public void setMessages(Map<String, SessionMessages> messages) {
this.messages = messages;
}
@Transient
@PrePersist
public void prepersist() {
if(StringUtils.isBlank(conferenceabbr))
conferenceabbr = ((ApplicationController)
JSFUtils.getManagedBean("applicationcontroller")).getConfabbr();
Map<String, SessionMessages> msgs = getMessages();
Iterator<SessionMessages> iter = msgs.values().iterator();
HashSet<SessionMessages> set = new HashSet<SessionMessages>();
while(iter.hasNext()) {
set.add(iter.next());
}
setSessionmessages(set);
if (orderattr == null) {
setOrderattr(100L);
}
}
@Transient
@PreUpdate
public void preupdate() {
prepersist();
}
public Set<SessionMessages> getSessionmessages() {
return sessionmessages;
}
public void setSessionmessages(Set<SessionMessages> sessionmessages) {
this.sessionmessages = sessionmessages;
}
}
With the Base Entity being
public interface BaseEntity {
public String getConferenceabbr();
public void setConferenceabbr(String conferenceabbr);
public Long getId();
}
If you need the model schema I will make a diagram...
Thanks for your fast response
Werner
> -Patrick
>
> On Jan 22, 2008 12:56 AM, Werner Punz <we...@gmail.com> wrote:
>> Hi I tried to move a project over to openjpa yesterday
>> I get the message that my entities mix annotations on properties
>> and methods.
>>
>> The main problem is, that
>> I have all my annotations set on the properties themselves
>> but I have a @PrePersist annotation set on a trigger method
>> which does some prepersist application logic!
>> All other annotations are directly on the instance variables
>> which define the properties! No other one is on any method!
>>
>> JPA and Hibernate Annotations takes my entities as given and do not
>> choke on them, OpenJPA does.
>>
>> This seems like a bug to me, am I right?
>>
>> Version of openjpa, current stable version!
>>
>>
>> Werner
>>
>>
>
>
>
Re: Weird problem/bug
Posted by Patrick Linskey <pl...@gmail.com>.
Hi,
Can you post the domain model that's causing the problems? Does the
superclass use the same access type as the subclasses?
-Patrick
On Jan 22, 2008 12:56 AM, Werner Punz <we...@gmail.com> wrote:
> Hi I tried to move a project over to openjpa yesterday
> I get the message that my entities mix annotations on properties
> and methods.
>
> The main problem is, that
> I have all my annotations set on the properties themselves
> but I have a @PrePersist annotation set on a trigger method
> which does some prepersist application logic!
> All other annotations are directly on the instance variables
> which define the properties! No other one is on any method!
>
> JPA and Hibernate Annotations takes my entities as given and do not
> choke on them, OpenJPA does.
>
> This seems like a bug to me, am I right?
>
> Version of openjpa, current stable version!
>
>
> Werner
>
>
--
Patrick Linskey
202 669 5907