I’m not sure if I’m asking the question the way it should be
but I am trying to create a new account in my project and for that method I want my USER Entity to be CascadeType.ALL , but just for this creating account method only. Not for any other method using the USER class.
Like if I want to use FetchType.LAZY at the run time for some particular method I implement it in criteria as criteria.setFetchType.LAZY and not inside my Entity.
In the same way, can I implement CascadeType.ALL at the run time of my application?
Here is my entity class in which i am Applying Cascade, its working fine
public Class UserEntity implements Serializable
@Cascade({ CascadeType.ALL })
@JoinColumn(name="teamId")
private TeamEntity teamId;
}
Here is my method in which i am using this cascade functionality , Now i just want this cascade functionality to define inside this method and remove from the entity
Is that possible ?
public String addTeam(UserEntity userInfoEntity) throws Exception{
Session session = sessionFactory.openSession();
try {
Transaction tr = session.beginTransaction();
Criteria crit = session.createCriteria(UserInfoEntity.class);
set cascade to
@Cascade({ CascadeType.Save })then only save operations (which are only happen in creating the user right?) will cascade.