1

I want to combine both Cassandra and Hibernate data sources in Grails domain classes; some domain classes have to be mapped with Hibernate and others have to be mapped with Cassandra.

I used (static mapWith = "cassandra") in the domain classes but still Cassandra maps all domain classes in the project.

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
Hanan Awwad
  • 63
  • 10

2 Answers2

1

That is currently a limitation with the Cassandra GORM implementation. Even if it won't be used by with Cassandra all domains needs to be mapped to table. I mean to add support for only using some of the domains in Cassandra it isn't yet done.

So currently you would need to create the whole schema in Cassandra as well as MySQL.

Jeff Beck
  • 3,944
  • 3
  • 28
  • 45
  • What about using cassandra orm plugin – Hanan Awwad Apr 02 '15 at 03:35
  • The Cassandra orm plugin is based on the older Cassandra thrift table structures. It does not require all tables be mapped. It has many things built in but to me is at the end of its life. Also it can be odd when the dynamic methods get applied. – Jeff Beck Apr 02 '15 at 04:16
  • then what do you prefer ? to use cassandra orm or map all the schema to cassandra database using cassandra gorm ? – Hanan Awwad Apr 02 '15 at 07:05
  • I would use the java native driver directly, since all your interactions with the domain should be going through at the service layer you can easily introduce a service that deals with CRUD operations in Cassandra for each item. Also modeling your data in C* is more focused on the queries then the data itself, so using GORM or ORM as a mapper can be tricky. – Jeff Beck Apr 02 '15 at 13:54
0

Although currently all domain classes will have a Cassandra table created, static mapWith = "cassandra" will only persist a domain to Cassandra only.

Not having any mapWith will result in the domain class being persisted using Hibernate to a database.

See the docs for more information.

If you don't want a class to be persisted at all, move it to src/groovy as detailed in the answer for this question Grails Entity without persist.