Enum Support in Management center - java

I do not see Enum Serialization/Deserialization support in hazelcast Management center.hazelcast-management-center SQL-Browser
Is there any other way to deal with enumeration? Help would be appreciated. Thanks in advance.
Expecting support for java enums to be stored as varchar like SQL and other DB SQL DB Screen

Related

Spring Data Cassandra - create a table with options values

Is there any way to create a table with non-default options values? So far, the #Table annotation was enough for my needs, but I need to set up a TTL value different than default. I use version 1.5.15.
Thanks in advance for help.
No, there is no option support derived from annotations. You can create tables by using CreateTableSpecification.
CreateTableSpecification.createTable("mytable").with(TableOption.COMMENT, "my comment");
Spring Data for Apache Cassandra isn't really a CQL object generation framework. The schema support is limited to basic usage to "just spin up the objects" without the need to always have a pre-provisioned keyspace.

What benefits MyBatis provides over working with plain JDBC

I need to write pretty straight forward DB code and I'm considering MyBatis over plain JDBC (I believe full ORM is an overkill).
Considering that in both MyBatis and plain JDBC you find yourself:
Hand writing SQL statements.
Manually wiring DB rows to JAVA DTO objects (either via code or config).
The MyBatis benefits over JDBC I know of are:
Out-of-the-box table/query caching.
Dynamic SQL.
SQL is stored outside of the code.
Templating SQL for easier DB vendor Independence.
What other MyBatis-Over-JDBC benefits are there to consider?
I dont know you'll count this one as advantage or not but there's MyBatisGenerator, And It generates all basic needed Queries plus some Advanced Queries too and DTO objects automatically based on a single XML file.
Plus it has Eclipse Plugin For the same.
Most of the times you do not need to map explicity columns to pojos so bullet number 2 is a difference rather than a similarity.
The main difference IMHO is the API that is much simpler in MyBatis than in JDBC. If used with Spring or Guice you will not need to call MyBatis API in your code at all.
Mappers and injection helps the testing a lot because mappers are plain interfaces so easy to mock.
About : 'Manually wiring DB rows to JAVA DTO objects (either via code or config).'
This is not totally true, if you use conventions you can get an automatic mapping from DB tables to Java classes, example you have a CUSTOMER table that has fields like ID, COMPANY_NAME, PHONE_NUMBER, and a Java class Customer with properties id, companyName and phoneNumber, MyBatis is smart enough to figurate the DB to camel case convention and no mapping is required from you. Great!
MyBatis require less code and is cleaner than plain JDBC coding
MyBatis supports named parameters, JDBC supports only placeholders? (ugg!)
With a single line you can change from Reuse Prepared Statement Mode to Bath Mode, in plain JDBC it will take you a rewrite of your code.

How do you change the schema in an OO database such as DB4O?

Just getting started with DB4O object oriented database.
I'm very familiar with SQL, if I upgrade the app and add a new field I just go into a SQL manager, change the schema, and initialize a new field with some manual SQL.
What is the process with an OO database such as DB4O? Is it similar?
Short answer: as long as you are only adding fields, db4o will take care of schema management for you.
For more details, check the db4o reference documentation about "Refactoring and Schema Evolution". Also, you can check out the "Schema evolution" chapter in "The Definitive Guide to db4o"

Is there a database modelling library for Java?

Does anyone know of a Java library that provides a useful abstraction for analyzing and manipulating arbitrary relational database schemata? I'm thinking of something that could do things like
LibraryClass dbLib = ...;
DbSchema schema = dbLib.getSchema("my_schema");
List<DbTable> tables = schema.getTables();
and
DbTable myTable = ...
for(DbColumn col : myTable.getColumns()){
... = col.getType();
}
or even manipulate tables like
myTable.addColumn(
new DbColumn("my_new_column", Type.UNSIGNED_INTEGER);
);
DbColumn myColumn = ...
myTable.removeColumn(myColumn);
Most Database modeling tools will have such an abstraction internally, but is there one in Java that I can use, or will I have to roll my own?
JDBC itself has such an abstraction. Look at java.sql.DatabaseMetaData. However, this is an optional part of the standard and it depends on the JDBC driver you are using wether it is implemented or not.
DdlUtils has what you're looking for. You can read/write schemas to/from XML (in Torque format) or a live database, or even define the database schema in pure Java. Better yet, read the on-line doco, it's quite good.
I haven't used it in years but Hibernate used to have tools for manipulating data models at build time. Hibernate also has the notion dialects which would be helpful if you're targeting more than one database vendor.
When I was at MetaMatrix, we built such a thing using EMF (Eclipse Modeling Framework) where we created a representational meta-model in UML, then generated it from code. The nice thing about metamodeling is that if you do it well, you can interoperate things across metamodels, provided you have made good choices against the meta-meta-model.
We also had an importer that would import metadata from the JDBC API and create the appropriate equivalent model objects (database, table, column, keys, etc).
This code might be open source some day since they got bought by JBoss but I don't think it is yet.

JPA - map entity to sql query?

I'm writing a JPA connector to a legacy sistem. The problem is, DB design in the system is.. well.. horrible.
I need to implement an entity that maps to three tables. I can do it using named sql queries, but the probem is, I have to use this entity in a OneToMany relation (this entity is on the many side). So how do I tell JPA it needs to use a specific named query with specific parameter?
And a subquestion: does any1 have any good on-line JPA documentation? I can't find anything decent :-/
I haven't actually found a way to do this with JPA. To solve problems like this I ended up using a named query.
As far as documentation, I have been using TopLink's and Hibernate's.
If you find a better way, please post it here!
Could you make a database view and then create an entity that maps onto that view? I don't know if this is possible, just a thought.
Take a look at #SecondaryTable(s). There's some examples of this in the Pro EJB 3 Java Peristance API book, page 237.

Categories