• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Question on ejbCreate().

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two beans. Person and Address with one-to-many relation.

When I create Address using ejbCreate, I am setting all the address fields and in ejbPostCreate() I am setting setPerson(person).

My question is: can I set a field of Person in ejbCreate of Address bean?
 
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My question is: can I set a field of Person in ejbCreate of Address bean



Since the Person bean is still not creted a refernce to Person EJB from Address bean cannot be obtained.
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you need to tune the relationship fields, let Person have an instance field that referers to an Address entity, instead of the Address entity having a instance field of a Person.
 
Mayuri Roi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradip, I already have persons created. And also, I am passing Person reference in ejbCreate of Address.

Daniel, Person has a relationship field of Address as 'addresses' that gives me person.getAdrressess() and person.setAddresses().
Also, Address has a relationship field of Person as 'person' that gives me address.getPerson() and address.setPerson().

What I am trying to do is...

in Address Bean...

ejbCreate(AddressDTO dto, Person parentPerson) ... {
//some business logic...
...
//Set address fields... ex:
setName(dto.getName());
setField2(dto.getField2());
...
...
//THE FOLLOWING LINE IS WHAT I WOULD LIKE TO DO... BUT NOT SURE OF ANY IMPLICATIONS
parentPerson.setSomeField(someValue);

//continue setting other address fields...
setField3(dto.getField3());
....
}
ejbPostCreate(AddressDTO dto, Person parentPerson) ... {
setPerson(parentPerson);
}
 
Pradeep bhatt
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mayuri

Yes , you can set the fields of the Person field.
 
I've never won anything before. Not even a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic