Java Code Examples for org.springframework.data.jpa.domain.AbstractPersistable

The following examples show how to use org.springframework.data.jpa.domain.AbstractPersistable. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-data-jpa-extra   Source File: BaseEntity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object obj) {

    if (null == obj) {
        return false;
    }

    if (this == obj) {
        return true;
    }

    if (!getClass().equals(ClassUtils.getUserClass(obj))) {
        return false;
    }

    AbstractPersistable<?> that = (AbstractPersistable<?>) obj;

    return null != this.getId() && this.getId().equals(that.getId());
}
 
Example 2
@SuppressWarnings({ "unchecked", "rawtypes" })
private <S extends T> EntityInformation<Object, S> getEntityInformation(S entity) {

	Class<?> userClass = ClassUtils.getUserClass(entity.getClass());

	if (entity instanceof AbstractPersistable<?>) {
		return new JpaPersistableEntityInformation(userClass, entityManager.getMetamodel());
	}

	return new JpaMetamodelEntityInformation(userClass, entityManager.getMetamodel());
}