oauth - How to map a third-party property in Hibernate -
i have class (activity) field (signaturesecret) defined interface (signaturesecret), implementation of (sharedconsumersecret) comes spring security oauth package.
when persisting instances of class hibernate, want use specific property of sharedconsumersecret value should saved/loaded database. can't annotate sharedconsumersecret, it's part of spring framework.
is there way this?
@entity public class activity implements consumerdetails { @transient private list<grantedauthority> authorities = new arraylist<grantedauthority>(); private string consumerkey; private string consumername; @id @generatedvalue(strategy = generationtype.auto) private integer id; @manytoone private activityowner activityowner; //this tricky 1 private signaturesecret signaturesecret; @size(min = 1, max = 36) private string uuid; ...
the way around can think of have one-to-one relationship of signaturesecrets activities, seems bit silly.
i want use specific property of sharedconsumersecret value should saved/loaded database
you'll need implement usertype signaturesecret. need know how convert object value (probably string), , how convert string object.
see example hibernate test suite on how build usertype: https://github.com/hibernate/hibernate-core/blob/master/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/phonenumbertype.java
Comments
Post a Comment