-
I have an object with an embedded object, which can be null.
When the object is created, there are no errors. Only when updated: NO2.6003: id can not be null |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 9 replies
-
Can you please provide the code update and the version of nitrite you are using? |
Beta Was this translation helpful? Give feedback.
-
I use version 3.4.3. Initializing the database:
Inserting, updating and removing
|
Beta Was this translation helpful? Give feedback.
-
I am a bit confused. The id of the user object is not null. Which id is null here? |
Beta Was this translation helpful? Give feedback.
-
I have the attribute nitriteId deleted now. The id field is now the attribute uuid. Now it works. |
Beta Was this translation helpful? Give feedback.
-
Sorry for the late reply. Can I close this issue now if you have found the solution? |
Beta Was this translation helpful? Give feedback.
-
My "solution": I use the field uuid as id and "ignore" the nitrite id:
|
Beta Was this translation helpful? Give feedback.
-
Sorry again for belated reply, got a little tied up with my day job, so could not pay attention to your issue. The problem here is with the @Indices({
@Index(value = "uuid", type = IndexType.Unique),
@Index(value = "emailAddress", type = IndexType.Unique)
})
public class User extends PersistentObject {
@Id
private NitriteId nitriteId;
private String uuid = UUIDFactory.generateUUID();
private String emailAddress = UUIDFactory.generateEMailAddress();
....
private RunningPlan activeRunningPlan; // current training, can be null
@Override
public Document write(NitriteMapper mapper) {
Document document = new Document();
document.put("nitriteId", nitriteId);
document.put("uuid", uuid);
document.put("firstName", firstName);
document.put("lastName", lastName);
document.put("emailAddress", emailAddress);
document.put("birthday", birthday); Do this and your issue will be resolved. |
Beta Was this translation helpful? Give feedback.
Sorry again for belated reply, got a little tied up with my day job, so could not pay attention to your issue. The problem here is with the
write
method inUser
class. You also have to writenitriteId
field in the document like other fields. As you are handling the serialization and deserialization manually, you have to take care of each and every field of your object.