Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Mapping Dynamic Properties to JPA/Hibernate

Hi, I have a class that looks like:

@SpaceClass
public class A {
  String name;
  DocumentProperties dynamicProperties = new DocumentProperties()
  //other properties...

  @SpaceDynamicProperties
  public DocumentProperties getDynamicProperties() {
    return dynamicProperties;
  }

  //other methods...
}

How can I map my class to be persisted (using mirror service) into a relational database where each dynamicProperties.key would be a table A.column and dynamicProperties.value would be a table A.row. Example:

A entity1 = new A("any1");
entity1.getDynamicProperties().setProperty("my_dynamic_column", "22")

A entity2 = new A("any2");
entity2.getDynamicProperties().setProperty("my_dynamic_column", "33")

A entity3 = new A("any3");
entity3.getDynamicProperties().setProperty("my_other_dynamic_column", "99")

Would produce a table like:

TABLE A
name | my_dynamic_column | my_other_dynamic_column
any1 |       22          |        null
any2 |       33          |        null
any3 |      null         |         99

Thanks!

asked 2014-11-18 15:28:19 -0500

Christian gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Hi Christian, In order to do such mapping you should implement synchronization end point that knows how to refresh schema I found for example : http://www.infoq.com/articles/hiberna... , you can probably find newer links, Currently ,we are not aware of customers using this approach,usually when dynamic properties are a requirement,non sql db are used.So please let us know if you encounter any issue in implementing it.

Regards Ester.

answered 2014-11-20 02:05:36 -0500

Ester gravatar image
edit flag offensive delete link more

Comments

I suggest you have getter and setter methods for the relevant fields but mark these to be excluded (@SpaceExclude) on the getter.

This will allow hibernate to use the object like any other POJO but have XAP POJO reflection process to ignore these methods when inspecting the class and registering it internally.

To reload new Space and mirror PU with new code and hibernate mapping without losing data you can use the hot deploy utility. See:

http://docs.gigaspaces.com/sbp/xap-ho...

shay hassidim gravatar imageshay hassidim ( 2014-11-20 11:01:51 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-18 15:28:19 -0500

Seen: 1,203 times

Last updated: Nov 20 '14