Closed wquintanilhadasilva closed 5 years ago
There isn't @PrePersist
annotation. Show me your class please. Which version are you using?
Sorry, I edited the annotation name. The correct name is @PreCallBack :-)
Method in the business class
public class Item {
@Getter() @Setter()
private String _id;
@PreCallBack(scope = CallbackScope.ADD)
public void generateId() {
if (!this.prefix.equals(EntityPrefix.NONE.toString())) {
this._id = this.prefix + DateTimeUtils.nowUTCTimeStampString();
}
}
}
Call the Repository in the service:
public class ItemService extends BaseService {
private Repository repository = super.getRepository();
...
public void save(Item item) {
item = this.repository.add(item);
}
...
}
Sorry about delay, happy new year :)
This error is present in the versions 0.6.0.M43
and 0.6.0.M44
, the version 0.6.0.M45
was released fixing that. An unit test case was wrote to not repeat again.
<dependency>
<groupId>net.sf.jkniv</groupId>
<artifactId>jkniv-whinstone-couchdb</artifactId>
<version>0.6.0.M45</version>
</dependency>
Fixed 0.6.0.M45
version.
In save operations, the framework is calling @PrePersist methods twice.