DATACMNS-357 - Test case for new state detection for entities with primitive ids.
Ignore test case for EclipseLink as it throws an exception complaining about long being used where Long is expected. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=415027
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.jpa.domain.sample;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Entity
|
||||
public class SampleWithPrimitiveId {
|
||||
|
||||
@Id long id;
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,13 @@ public class EclipseLinkJpaMetamodelEntityInformationIntegrationTests extends
|
||||
@Ignore
|
||||
public void findsIdClassOnMappedSuperclass() {}
|
||||
|
||||
/**
|
||||
* Ignored due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=415027
|
||||
*/
|
||||
@Override
|
||||
@Ignore
|
||||
public void detectsNewStateForEntityWithPrimitiveId() {}
|
||||
|
||||
@Override
|
||||
protected String getMetadadataPersitenceUnitName() {
|
||||
return "metadata_el";
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
import org.springframework.data.jpa.domain.sample.SampleWithIdClass;
|
||||
import org.springframework.data.jpa.domain.sample.SampleWithIdClassPK;
|
||||
import org.springframework.data.jpa.domain.sample.SampleWithPrimitiveId;
|
||||
import org.springframework.data.jpa.domain.sample.User;
|
||||
import org.springframework.data.jpa.domain.sample.VersionedUser;
|
||||
import org.springframework.data.repository.core.EntityInformation;
|
||||
@@ -138,6 +139,22 @@ public class JpaMetamodelEntityInformationIntegrationTests {
|
||||
assertThat(information.getIdType(), is((Object) BaseIdClass.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-357
|
||||
*/
|
||||
@Test
|
||||
public void detectsNewStateForEntityWithPrimitiveId() {
|
||||
|
||||
EntityInformation<SampleWithPrimitiveId, Long> information = new JpaMetamodelEntityInformation<SampleWithPrimitiveId, Long>(
|
||||
SampleWithPrimitiveId.class, em.getMetamodel());
|
||||
|
||||
SampleWithPrimitiveId sample = new SampleWithPrimitiveId();
|
||||
assertThat(information.isNew(sample), is(true));
|
||||
|
||||
sample.setId(5L);
|
||||
assertThat(information.isNew(sample), is(false));
|
||||
}
|
||||
|
||||
protected String getMetadadataPersitenceUnitName() {
|
||||
return "metadata";
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<class>org.springframework.data.jpa.domain.sample.SampleEntity</class>
|
||||
<class>org.springframework.data.jpa.domain.sample.SampleEntityPK</class>
|
||||
<class>org.springframework.data.jpa.domain.sample.SampleWithIdClass</class>
|
||||
<class>org.springframework.data.jpa.domain.sample.SampleWithPrimitiveId</class>
|
||||
<class>org.springframework.data.jpa.domain.sample.VersionedUser</class>
|
||||
<class>org.springframework.data.jpa.domain.sample.AbstractMappedType</class>
|
||||
<class>org.springframework.data.jpa.domain.sample.ConcreteType1</class>
|
||||
|
||||
Reference in New Issue
Block a user