How to atomically update a map key in Aerospike? - aerospike

#AerospikeEntity(nameSpace = Constants.NAMESPACE, setName = Constants.ABC_SET)
public class ABCModel implements Serializable {
private static final long serialVersionUID = 1L;
#AerospikeKey
private String cycle;
private long debitAmount;
private long creditAmount;
private Map<String, AtomicDouble> map;
}
suppose atomically i want to update some key inside this given map ,how can i achieve this in Aerospike java client ?

Please see code examples here: https://github.com/aerospike/aerospike-client-java/blob/master/examples/src/com/aerospike/examples/OperateMap.java

Related

Entry and Serialisation

My project is in the form:
Class Persistant :
#Entity
public class Produit implements Serializable {
private static final long serialVersionUID = -3352484919001942398L;
#Id
#GeneratedValue
private Long id;
private String module;
private String produit;
//getter&&setter
Class Dao
public List<Entry<Integer, List<Produit>>> parProduit(String cat) {
.......
HashMap<Integer, List<Produit>> legaux = new HashMap<Integer, List<Produit>>();
........
List<Map.Entry<Integer, List<Produit>>> entries = new ArrayList<Entry<Integer, List<Produit>>>(legaux.entrySet());
return entries;
}
when i execute this code i get this error :
java.io.NotSerializableException: java.util.HashMap$Node
java.util.HashMap.EntrySet<K, V>
is not serializable.
legaux.entrySet()
probably returns set of type java.util.HashMap.EntrySet, you may want to check that.

How to use RedisTemplate to store different datatypes

I am using Spring RedisTemplate to deal with operations related to Redis. Will I be able to store two datatypes. For example I want to store Key,String as well as Key,Integer. How to acheive this?
Have you read http://docs.spring.io/spring-data/redis/docs/current/reference/html/redis.html ?
Altering a bit from docs, untested:
public class Example {
// inject the actual template
#Autowired
private RedisTemplate<String, String> template;
// inject the template as ValueOperations
#Resource(name="redisTemplate")
private ValueOperations<String, Integer> intOp;
#Resource(name="redisTemplate")
private ValueOperations<String, String> stringOp;
public void sampleKeySetting() {
intOp.set('my_int_value', 10);
stringOp.set('my_string_value', 'good!');
}
}
There are XXXXOperations for other data structures too: check http://docs.spring.io/spring-data/data-keyvalue/docs/current/api/org/springframework/data/keyvalue/redis/core/RedisOperations.html

JPQL JOIN doesn't return results

My JPQL JOIN query doesn't return any results.
I'm trying to join TargetBean and TipBean on the TargetBean primary key:
public class TargetBean implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
#Entity
public class TipBean implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
#OneToOne
#PrimaryKeyJoinColumn
private TargetBean target;
My query looks like this:
List<Object[]> tipList =
(List<Object[]>)em.createQuery("SELECT tb.result, tg.actualResult "
+ "FROM TipBean tb JOIN tb.target tg")
.getResultList();
Do you notice something wrong with this query or what goes wrong?
Try removing the #PrimaryKeyJoinColumn annotation, I don't think it is appropriate in this context (it is used with inheritence).

Map (integer integer) mapping in hibernate

How would you annotate this bean to be mapped in hibernate ?
#Entity
public class PerformanceValues implements Serializable{
private static final long serialVersionUID = 1234850675335166109L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
//key is mass, value is distance needed
private Map<Integer, Integer> massToDist;
}
Each performanceValues entity has a unique map, and each map can be related to only one PerformanceValues (I guess this is a oneToOne relationship)
Thanks

NotSerializableException in a ManagedBean with ViewScoped and Spring's services

This is the ManagedBean
#ManagedBean #ViewScoped public class DetailItem {
private static final long serialVersionUID = -7647929779133437125L;
#ManagedProperty(value = "#{itemServiceImpl}")
private ItemService servItem;
This is the Service
#Service("itemServiceImpl") #Transactional(value = "transactionManagerLocal") public class ItemServiceImpl implements ItemService {
private static final long serialVersionUID = 1L;
#Autowired
#Qualifier("itemDaoImpl")
private ItemDAO dao;
but when I try to access to the page that used 'DetailItem', I have the following exception:
java.io.NotSerializableException: org.springframework.dao.support.PersistenceExceptionTranslationInterceptor java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164) java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
To fix that I do the servItem transient and obtain it from the applicationContext. But I understand that it is not the correct solution and I dont find any other. Which is the proper way to do that?
I donĀ“t have the exception with sessionscoped or requestscoped.
Sounds like a similar problem like Serialization of ManagedProperty
Does ItemService implement Serializable and are all members of ItemServiceImpl serializable themselves?