Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] CacheCoordinationType usage

Hi;
I have an application deployed on glassfish cluster environment and doing
some sort of DB operations, and currently having problem with the following
case

There are two classes as follows;

@Cache(coordinationType =
CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, type = CacheType.FULL,
shared = true, size = 100, alwaysRefresh = true)
public class Users implements Serializable {
    @Id
    @Column(name = "USERID", nullable = false, insertable = true, updatable
= true, length = 100)
    private String                 userId;
    @ManyToOne
    @JoinColumn(name = "ProfileId", referencedColumnName = "ProfileId",
nullable = true, insertable = true, updatable = true)
    private Profiles         profile;

@Cache(coordinationType =
CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, type = CacheType.FULL,
shared = true, size = 100, alwaysRefresh = true)
public class Profiles implements java.io.Serializable {

    @Id
    @Column(name = "ProfileId", nullable = false, insertable = true,
updatable = true)
    private int                  profileId;

    @OneToMany(mappedBy = "Profile")
    private Collection<Users> profile;


somewhere inside the code i do the following operations
//Create a new user
User user = new User();

//Set profile which is already in DB for user
Profile profile =  entityManager.find(Policy.class, id)
user.setProfile(Profile);

//Insert user to DB
entityMan.persist(user);

right after this operation i get duplicate entry exception for profile,
because while inserting user to DB it also tries to insert Profile which is
already exist in DB. If I change
CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES to
CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS it works fine. As far as i
know i need to use SEND_NEW_OBJECTS_WITH_CHANGES in order to inform other
instances in the cluster for this newly created user object, 

Any comment?

Thanks

Seckin



-- 
View this message in context: http://www.nabble.com/CacheCoordinationType-usage-tp24860637p24860637.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top