Reputation: 1
I am trying to define auto_increment at properties of an attribute in my domain.
But I couldn't do it anywhere. Is that possible? If so, where can I check how to do it?
Upvotes: -1
Views: 358
Reputation: 392
You'll have to code your own auto increment feature. Take a look at conditional puts. If you're looking to build a unique identifier rather than a counter, keep UUIDs in mind as they're much easier and more efficient than hitting the database unnecessarily.
Upvotes: 1
Reputation: 4659
An below example shows you can auto increment the attribute names where value is greater then 1024, that is to be uploaded.
if (fieldvalue.length() >= 1024) {
int index = 1;
while (fieldvalue.length() >= 1000 && vlist.size() < 254) {
String value = new String(fieldvalue.substring(0, 1000).getBytes("UTF-8"), "UTF-8");
ItemAttribute objItemAttribute = new ItemAttribute(fieldname+index, value, fieldreplace.booleanValue());
vlist.add(objItemAttribute);
fieldvalue = new String(fieldvalue.substring(1000).getBytes("UTF-8"), "UTF-8");
index++;
}
}
Upvotes: 0