Any drawbacks to setting the generation strategy to native? 

From: "robertoschwald" <robertoschw...@gmail.com> 
To: "CAS Developer" <cas-dev@apereo.org> 
Sent: Wednesday, August 9, 2017 9:24:23 AM 
Subject: [cas-dev] CAS 5.x does not work with Galera JPA ticket registry 

Hi all, 

FYI. 

Currently CAS (5.x) does not play well with Galera db cluster when using JPA 
registries. 

In Galera, each table must hold a PK to support deletes ( 
https://mariadb.com/kb/en/mariadb/mariadb-galera-cluster-known-limitations/ ). 
Therefore, it is mandatory to set the MariaDB option 
"innodb_force_primary_key=1“, to ensure all tables hold a primary key. 

As the CAS Entity IDs are annotated with @GeneratedValue(strategy = 
GenerationType.AUTO), Hibernate (5.x) picks the table generator instead of 
identity, so tries to create the hibernate_sequence table in DDL. 
See https://hibernate.atlassian.net/browse/HHH-11014 

As the hibernate_sequence table does not have a PK, creation fails in Galera 
with: java.sql.SQLSyntaxErrorException: This table type requires a primary key. 
Also, performance is quite bad in MySQL, as the table generator uses an 
additional, separate transaction to fetch a sequence value. 

There are several approaches to workaround this issue: 

- Set generator=„native“ in @GeneratedValue 
- Change strategy to „SEQUENCE“ by default and provide a JPA XML mapping that 
overwrites the Java based annotation mapping (see 
https://vladmihalcea.com/2017/01/17/how-to-replace-the-table-identifier-generator-with-either-sequence-or-identity-in-a-portable-way/
 ) 
- Create the hibernate_sequence table manually and provide a ID PK column 
(nasty..) 
- Mark Galera as unsupported in CAS docs. 

Robert 


-- 
You received this message because you are subscribed to the Google Groups "CAS 
Developer" group. 
To unsubscribe from this group and stop receiving emails from it, send an email 
to cas-dev+unsubscr...@apereo.org . 
Visit this group at https://groups.google.com/a/apereo.org/group/cas-dev/ . 

-- 
You received this message because you are subscribed to the Google Groups "CAS 
Developer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cas-dev+unsubscr...@apereo.org.
Visit this group at https://groups.google.com/a/apereo.org/group/cas-dev/.

Reply via email to