Update your entity as:
@Entity
public class Tradesman extends User{
@ManyToOne(optional=false)
private Company company;
*@PrePersist*
public void hashPassword(){
setPassword(BCrypt.hashpw(**entity.getPassword(), BCrypt.gensalt());
}
And then check where are you persisting Tradesman without company.
2013/5/21 Thomas Broyer <[email protected]>
>
>
> On Tuesday, May 21, 2013 11:18:42 AM UTC+2, Nermin wrote:
>>
>> Dear GWT developers,
>>
>> I have a "probably simple" problem with my application which I am
>> obviously not able to solve.
>>
>> Two Classes: Company, Tradesman
>>
>> @Entity
>> public class Company {
>> @OneToMany(cascade = CascadeType.ALL, mappedBy = "company")
>> private List<Tradesman> users = new ArrayList<Tradesman>();
>>
>> ....
>> }
>>
>>
>> @Entity
>> public class Tradesman extends User{
>> @ManyToOne
>> private Company company;
>>
>> *@PrePersist*
>> public void hashPassword(){
>> setPassword(BCrypt.hashpw(**entity.getPassword(),
>> BCrypt.gensalt());
>> }
>>
>> *JSR 303 validation on GWT is activated.*
>>
>> Here is the *error message:
>> *Detected attempt to establish Company(no-id-yet) as the parent of
>> Tradesman(356) but the entity identified by Tradesman(356) has already been
>> persisted without a parent. A parent cannot be established or changed once
>> an object has been persisted.
>>
>> My problem is obviously that when I change some parameters within the
>> Tradesman entity within the *@PrePersist* method, a new child entity is
>> created.
>> In case I do not touch any parameter, in the @PrePersist, everything
>> works fine.
>>
>> What am I doing wrong here?
>>
>
> You're not reaching the appropriate group ;-)
>
> I suppose you're using AppEngine (form what I know of JPA, I can't see a
> reason for that kind of message, unless you're using JPA on AppEngine), in
> which case you can ask for support on StackOverflow:
> https://developers.google.com/appengine/community
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.