-
Notifications
You must be signed in to change notification settings - Fork 302
#671: add support for hana as dbType #671
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- Leave a large ID space reserved for master-data and test-data | ||
CREATE SEQUENCE HIBERNATE_SEQUENCE START WITH 1000000; | ||
|
||
-- hana does not support Dateadd function out of the box so we add it here to be able to use it for master-data SQLs | ||
CREATE FUNCTION DATEADD(IN DATETYPE NVARCHAR(256), IN NUMBER INTEGER, IN TS TIMESTAMP) | ||
RETURNS TSADD TIMESTAMP | ||
AS | ||
BEGIN | ||
IF :DATETYPE = 'DAY' | ||
THEN | ||
TSADD = ADD_DAYS(:TS, :NUMBER); | ||
ELSEIF :DATETYPE = 'HOUR' | ||
THEN | ||
TSADD = ADD_SECONDS(:TS, :NUMBER * 3600); | ||
ELSE | ||
SIGNAL SQL_ERROR_CODE 10000 SET MESSAGE_TEXT = 'Unsupported date type: ' || :DATETYPE; | ||
END IF; | ||
END; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- *** RevInfo (Commit log for envers audit trail) *** | ||
CREATE COLUMN TABLE RevInfo( | ||
id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1), | ||
"timestamp" BIGINT NOT NULL, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unquoted columns will be upper-cased while quoted columns will be mixed-case. So for consistency reasons you should name this column "TIMESTAMP". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason here is that we had to quote this property also in the JPA annotation as this is a reserved keyword in Oracle. For some reasons (case-sensitivity) in DDL for most databases this property then also has to be quoted in the same way. To keep this consistent we do it the same way for the DDLs of all database types. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW: Using "TIMESTAMP" in AdvancedRevisionEntity.java would indeed have been the better option for 2.6.x. Changing this again? Or leave it as is? |
||
userLogin VARCHAR(255), | ||
PRIMARY KEY (ID) | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- *** BinaryObject (BLOBs) *** | ||
CREATE COLUMN TABLE BinaryObject ( | ||
id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
modificationCounter INTEGER NOT NULL, | ||
content BLOB, | ||
filesize BIGINT NOT NULL, | ||
mimeType VARCHAR(255), | ||
CONSTRAINT PK_BinaryObject_id PRIMARY KEY(ID) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Property spring.jpa.database is set to hana, which is not a valid value. As of now hana database cannot be set explicitly using this property. So from the list of available values only DEFAULT seems to be a sensible choice and using it Hibernate is able to resolve the database correctly. So it is better to set this property to DEFAULT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting HANA via
spring.jpa.database
will be possible starting with Spring 5.1 (see Jira item https://jira.spring.io/browse/SPR-16460)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all your valuable feedback. Also great seeing how hana evolves and becomes first class citizen by all frameworks 👍
With this information, I would suggest not to change anything. We just leave it like this and it will get fixed in the future when the update to spring 5.1 takes place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hohwille but with the current setting application fails to startup. So until Spring 5.1 is available we need to provide a valid value that works for Hana.