spring-data


Spring Gemfire entity class id generation


Is it possible to use auto generated id in Spring Data Gemfire?
for example, if I have a class called MyGemfire
#region("myregion")
class MyGemfire{
#Id
#generatedValue????// if it is not possible what method I have to use to generate id in auto increment fashion?
Long id;
String name;
...
}
From a quick look at SimpleGemfireRepository it doesn't look like the repository is generating an ID:
#Override
public <U extends T> U save(U entity) {
ID id = entityInformation.getId(entity).orElseThrow(
() -> newIllegalArgumentException("ID for entity [%s] is required", entity));
template.put(id, entity);
return entity;
}
Also, this question and its answer suggest there is no ID generation in Gemfire itself.
So what you should do is to create your ID yourself. For example, it should be possible to have two constructors one taking an ID and the othe not taking an ID but generating it. A UUID would be the obvious choice. If you are bound to Long values, you probably have to roll your own algorithm.
To make it obvious to Spring Data which constructor to use when loading instances, you can use the #PersistenceConstructor annotation.

Related Links

#Autowired does not work in SimpleJpaRepository extension
#EnableJpaRepositories.enableDefaultTransactions = false not working
Spring Data JPA - Update Whole object
spring data load children and query by child property
What is the difference between all these spring DAO templates
Spring Batch and Neo4j: Transaction synchronization is not active
spring data not get id annotaion on method
spring jpa query dsl doesnt work with projection
Spring Elasticsearch data repository in Weld SE CDI - UnsatisfiedResolutionException
Spring Data query by example and Primefaces datatable filtering
spring-data-parent and spring-data-* projects with java 6?
SpringJPA + Eclipselink: No [ManagedType] was found for the key class. Not using persistance.xml
spring Batch partitioning + spring-data-mongo integration example
Trying to use Crate.io NoSql database with an existing Spring Data / Mysql project
How spring data generate sql according to method name?
Spring Data Jpa equality of two column

Categories

HOME
orientdb
typelite
cucumber
opencv-python
scroll
operating-system
command-prompt
code-formatting
openlayers-3
consul
liferay-7
elisp
swift2
turbojpeg
supercollider
sentry
position
cdi
minecraft
polymer-2.x
stack-overflow
lc3
locationmanager
angular4
rpmbuild
http-authentication
scheduled-tasks
spring-ldap
anova
liferay-6.2
intel
mod-wsgi
multi-dimensional-scaling
jsonresult
keyboard-layout
code-rally
android-alarms
gitolite
python-sounddevice
hdiv
vb.net-to-c#
virtual-memory
nomad
qvtkwidget
photoswipe
iptv
email-forwarding
gawk
annotatorjs
ternary-operator
visual-studio-monaco
xcode8-beta4
cdo.message
jtag
noclassdeffounderror
json-spirit
self
enaml
embeddedwebserver
windows-rt
siena
treeline
git-reset
jini
screwturn
hotswap
iosched
unrealscript
notifyjs
django-facebook
disjoint-union
postgres-xc
xs
eager-loading
dibs
smartfox
user-forums
coordinate
word-frequency
first-class
platform-independent
representation
jmenu
aggregator
reliability
j2mepolish
jquery-effects
error-detection

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App