Generator-jhipster: Remove ByteBuffer/ZonedDataTime Data Type from Cassandra Tests

Created on 25 Jan 2020  路  16Comments  路  Source: jhipster/generator-jhipster

Overview of the issue

While working on https://github.com/jhipster/generator-jhipster/issues/11169, I noticed that the Cassandra entities that we generate has ByteBuffer data type. This data type is not supported in our entity generation and if we try to import the jdl file such as the following using jhipster import-jdl <jdl-file-name> we will get an error.

entity CassBankAccount {
  userId UUID,
  name String required,
  bankNumber Integer,
  agencyNumber Long,
  lastOperationDuration Float,
  meanOperationDuration Double,
  balance BigDecimal required,
  lastOperationDate Date,
  active Boolean,
  picture ByteBuffer required,
  operationsFile ByteBuffer
}

In our CI we use jhipster --with-entities command and that seems to work with some warnings such as,

WARNING! Cannot use validation in .jhipster/CassBankAccount.json for field {
    "fieldName": "picture",
    "fieldType": "ByteBuffer",
    "fieldTypeBlobContent": "image",
    "fieldValidateRules": [
        "required"
    ]
} 
Hibernate JPA 2 Metamodel does not work with Bean Validation 2 for LOB fields, so LOB validation is disabled

My suggestion is to remove the ByteBuffer data type since there's no practical usage in testing something that the users cannot use as a datatype? :thinking: Let me know if you have alternative ideas on this. :smile:

Motivation for or Use Case

Remove ByteBuffer data type from tests since users cannot generate entities with that data type.

Reproduce the error

Create a simple project with Cassandra as database and with the given entities. The .yo-rc.json and the JDL file is given below. First generate the project using the .yo-rc.json file and then try to generate the entities with jhipster import-jdl <jdl-file-name>. You'll get the following error.

Error: The type 'ByteBuffer' is an unknown field type for field 'picture' of entity 'CassBankAccount'.
Related issues

Not that I know of.

Suggest a Fix

Maybe remove the ByteBuffer data type? :thinking:

JHipster Version(s)

JHipster v6.6.0

JHipster configuration
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "baseName": "sampleReactCassandraSessionRedis",
    "packageName": "io.github.jhipster.sample",
    "packageFolder": "io/github/jhipster/sample",
    "serverPort": "8080",
    "authenticationType": "session",
    "cacheProvider": "redis",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "cassandra",
    "devDatabaseType": "cassandra",
    "prodDatabaseType": "cassandra",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "rememberMeKey": "NDAzY2M3MWQyMTY2ZjgzMjM2MGY0NWJmMGQ0ZGEzYmNkMzE3N2JhNDgyMTg2Y2I5OTA4ZTQxNzNiZTRiY2IzOWZjM2ZhMzg5NDI4NzQyOGI4ZDIyNjRmNzY2MzMzM2JiMWZkZWFiMWRmOGU0MDFmMGJmMTU4NWQzMzM0ZDdkNmE",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "react",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "testFrameworks": ["gatling", "protractor"],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": ["en", "fr"],
    "blueprints": [],
    "jhipsterVersion": "6.6.0",
    "creationTimestamp": 1579850992835
  }
}
Entity configuration(s) entityName.json files generated in the .jhipster directory
entity CassBankAccount {
  userId UUID,
  name String required,
  bankNumber Integer,
  agencyNumber Long,
  lastOperationDuration Float,
  meanOperationDuration Double,
  balance BigDecimal required,
  lastOperationDate Date,
  active Boolean,
  picture ByteBuffer required,
  operationsFile ByteBuffer
}
  • [x] Checking this box is mandatory (this is just to show you read everything)
area cassandra

All 16 comments

I'm the one who coded ByteBuffer for Cassandra, long time ago - see https://github.com/jhipster/generator-jhipster/pull/3516/files

If we decide to remove this, does it mean we can't use "Blob" anymore with Cassandra ?

@pascalgrimaud : Good point, I haven't tested Blob data type on Cassandra yet, but what we can do is replace this ByteBuffer with Blob and also update the documentation to include blob. If this is in agreement I can do the change. :smile:

I also noticed that there's ZonedDateTime in our tests for Cassandra. I will try to remove that as part of this issue as well.

Why ? IIRC ZonedDatetime is supported on Cassandra.

@cbornet : Hmm... 馃 Are you sure; maybe I was a bit confused as I didn't see it in the list; http://cassandra.apache.org/doc/latest/cql/types.html. Thus I thought it's not. Also when zoned date time is used in a jdl file we get a error when running the jhipster import-jdl <file-name> command; I have to look at that more closely. 馃

so, what's the state of this ticket ?

@pascalgrimaud : It's in my to-do list. Could we wait a few days more ? :smile:

of course, no problem :)

Is there really something to do ? I think ByteBuffer (blob) and ZonedDatetime should be supported for Cassandra.

@cbornet : The problem is twofold.

1) Yes I do agree that Blob is a supported data type in Cassandra. However it seems to me that we don't support Blobs in Cassandra for the moment.

2) Again for ZonedDateTime, I don't think we support it currently for Cassandra but we do support it for other dbs.

Also note that our documentation doesn't mention support for Blobs or ZonedDateTimes in Cassandra; https://www.jhipster.tech/jdl/entities-fields#syntax (see Field Types and Validations section at the end).

So I would suggest;

1) Remove ZonedDateTime and ByteBuffer from tests (I mean since the tests don't reflect what a user can generate using a JDL file. i.e: If you do use ZonedDateTime or Blob or ByteBuffer in a JDL file you'll get an error such as;

Error: The type 'Blob' is an unknown field type for field 'picture' of entity 'CassBankAccount'.
ERROR! Error while parsing applications and entities from the JDL Error: The type 'Blob' is an unknown field type for field 'picture' of entity 'CassBankAccount'.

2) Support Blob for Cassandra? :thinking:

Let me know what you think :smile:

cc: @MathieuAA

Also on a related note, what is the way to test changes to jhipster-core without creating a release? Is there any documentation on this matter that I am missing? :smile:

@SudharakaP : lol, I think you can use these type by using directly the jhipster entity subgen. I coded the blob part 3 years ago and it has never been included in jdl... it confirms we have very very few Cassandra users

A release of JCore is necessary. There's no way to avoid that yet.

I've done a simple PR removing these unnecessary data types from Cassandra tests. The supporting of Blobs for Cassandra is a thing of it's own I think; we'll do it when the need arises.

As mentioned in the PR I submitted we need to add these two data types (ByteBuffer and ZonedDateTime) to the JCore side. Will look into it. 馃槃

I coded the ZonedDatetime support for Cassandra. So I'm sure it used to be supported.

@cbornet : Okay, I was unable to find a place where it is mentioned exactly; maybe I was looking at the wrong place. But I trust you on that. 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Steven-Garcia picture Steven-Garcia  路  3Comments

RizziCR picture RizziCR  路  3Comments

DanielFran picture DanielFran  路  3Comments

dronavallisaikrishna picture dronavallisaikrishna  路  3Comments

trajakovic picture trajakovic  路  4Comments