Skip to content

@Version value not getting back into PropertyBox #161

@vaithu

Description

@vaithu

I've a domain class like this

`
@entity
@table(name = "test1")
public class TestJpaDomain1 implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@Column(name = "keycode")
private Long key;

@Version
private int version;

@Column(name = "strv")
private String stringValue;

@Column(name = "decv")
private Double decimalValue;



public int getVersion() {
	return version;
}

public void setVersion(int version) {
	this.version = version;
}

public long getKey() {
	return key;
}

public void setKey(long key) {
	this.key = key;
}

public String getStringValue() {
	return stringValue;
}

public void setStringValue(String stringValue) {
	this.stringValue = stringValue;
}

public Double getDecimalValue() {
	return decimalValue;
}

public void setDecimalValue(Double decimalValue) {
	this.decimalValue = decimalValue;
}

}And a test class like this
@SpringBootTest
@activeprofiles("standard")
public class SriniTest {

@Configuration
@EnableAutoConfiguration
@EntityScan(basePackages = "com.holonplatform.jpa.spring.boot.test.domain1")
protected static class Config {

}

@Autowired(required = true)
private Datastore datastore;

private final static PathProperty<Long> KEY = PathProperty.create("key", long.class);
private final static PathProperty<String> STR = PathProperty.create("stringValue", String.class);
private final static PathProperty<Double> DEC = PathProperty.create("decimalValue", Double.class);
private final static NumericProperty<Integer> VERSION = NumericProperty.integerType("version");

private final static PropertySet<?> PROPERTIES = PropertySet.builderOf(KEY, STR, DEC, VERSION)
        .identifiers(KEY, VERSION)
        .build();

private final static DataTarget<TestJpaDomain1> TARGET = JpaTarget.of(TestJpaDomain1.class);

@Test
@Transactional
public void testDatastore() {

    PropertyBox propertyBox = PropertyBox.builder(PROPERTIES).set(KEY, 7L).set(STR, "Test ds").set(DEC, 7.7)
            .build();
    datastore.save(TARGET, propertyBox, DefaultWriteOption.BRING_BACK_GENERATED_IDS);
    System.out.println(propertyBox);

    Optional<Long> found = datastore.query().target(TARGET).filter(KEY.eq(7L)).findOne(KEY);
    assertTrue(found.isPresent());

    propertyBox = datastore.query(TARGET).findOne(PROPERTIES).get();
    System.out.println(propertyBox);
}

}`

The problem here is, the version is not coming back to the propertyBox. Please let me know how to get it back

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions