mybatis avoid generating model class *WithBLOBs - jpa

I have to change a column from varchar2 to clob. After generation mybatis creates a *WithBlobs class with fields that extends the original class. To avoid several impacts it would be possible to avoid the creation of the *WithBlobs class ?
Is there a configuration in MyBatis GeneratorXML Configuration File Reference that allows this ?

You can set the default model type to "flat" in your configuration. With that setting, only a single model class will be generated that contains all fields.
<generatorConfiguration>
<context defaultModelType="flat">
...
<context>
</generatorConfiguration>

Related

How can I modify Edm types in olingo by mapping in Olingo

In MySQL the column that are boolean are modeled via bit(1) or byte(1).
When I am using Olingo/Jpa beside MySQL and generate the entities in the Eclipse, it will assign type byte to these columns. It means in the metadata we will have something like this:
<Property Name="Deleted" Type="Edm.Byte" Nullable="false"/>
How can I modify the EDM type like the following?
<Property Name="Deleted" Type="Edm.Boolean" Nullable="false"/>
What I want to do is to do this modification with a mapping file, something like what explained here. (By this tutorial we can only change the names and not the types!)
Please note that I make eclipselink-orm.xml also automatically. I don't want to modify this file but it seems the type can be changed there as it has a line like this:
<basic name="deleted" attribute-type="byte">
However I don't want to modify this file each time while I generate it via Eclipse. Is there anyway that I extend some attributes there and inherent the rests?
It is not possible by olingo mapping file. This file is used only for renaming or exclusing the attributes or sets. We need to generate eclipselink-orm.xml file. You don't need to do the steps by hand. You can easily select the Dynamic Entities from Tables menu from JPA menu like this wizard:
And then define the suitable mapping types for the intended columns as follows in the last step of the wizard.
For example here in the above figure I defined the boolean for column deleted for table conditions or the entity condition!

How to make mybatis to map a list to Object

I have a device table which defines the device entity:
device:
id:
type:
And I have a attribute table which records the device's attributes:
device_attr:
device_id:
key:
value:
How can I write the mappers to save the device POJO into the table and how to load the attributes into the POJO? thanks.
Pivot function may meet this, but, mysql doesnt support it, and it's performance is not good.
In order to save the object you can use dynamic sql to iterate over POJO properties and generate INSERT statements similar to what is described in How to use MyBatis to iterate all fields of an object? :
<bind name="deviceProperties"
value="#org.apache.commons.beanutils.BeanUtils#describe(myDevice).entrySet()" />
<foreach index="propertyName" item="propertyValue" collection="deviceProperties">
INSERT INTO device_attr (key, value) values (
${propertyName}, ${propertyValue});
</foreach>
There is no out of the box solution to do the same for the select.
You need to do what is called table pivot but this is very database specific.
Another option is to recreate the POJO from the list of fields in java. It can be done in mapper using default methods like described in this answer.

Apache Ignite generated key for cluster but no key class

I used Ignite Web Console to generate a cluster configuration for an existing database. One of the tables in question has no key--it consists of two columns, both integers, neither of which is a key. There is a foreign key constraint that one of the columns must exist in another table, but I don't especially care about that.
In the generated cluster xml, each of the two columns is represented as a value field. These two fields match up with the generated POJO class as well. However, in the "keyType" field of the cluster config, it references a generated key class that, as far as I can tell, does not exist. If the POJO class for the table is Foo, then the key class is written down as FooKey, but this class does not exist in the project, and there is no definition for what fields would be in the key.
What am I supposed to do when referencing this cache? Do I need to create an implementation of this key class myself? When I make calls to the cache, does it need to be in the Entry format? How does the key-value store work when there is no key in the original table?
I think you’ll need to add these fields manually to "keyType". In order to do this find a model in Advanced -> SQL Scheme, then select two columns in "Key fields" dropdown menu. This will generate the FooKey.

Discriminator Column Type

I've been looking at various Code First examples of TPT (Table Per Type) in Entity Framework.
I have an abstract base class with 4 concrete implementations, all of which share the exact same interface. These are being stored using EF in a single table named after the abstract base class.
What I wish to do is use the EF Discriminator column, but without using the automatic table creation in Code First, instead adding the configuration and mappings manually. Does anyone know if this would be possible and if so, what the type of the Discriminator column is (name, type, length, nullable, etc.) so I can create one manually?
Many thanks.

EntityFramework inheritance - Ignore not nullable column

I have an one entity in my edmx model having an one property that can contains huge XML data.
Basically I want to load this entity without this property (column) /* huge data loading */ . And load this column only when it is strictly needed.
I have tried to create an inherited entity containing this property and remove this property from base entity (original entity). I have done mapping.
At this time I have problem, that during compilation a I get error, that base entity is not capable to insert and update itself, because property is not nullable
I am looking for best approach (solution) how this situation should be solved.
I am attaching the cut-out from my emdx designer (containing my current and desired situation)
UPDATE:
I will try to write a procedure that I have tried:
I mapped functions to my custom functions. For entity TRP_TechReport_T without the XML column (property). Then I just mapped for entity TRP_TechReport_T functions to my custom function (containing XML column).
Then I set Mapping condition on the entity TRP_TechReport_T: When TRP_XML = Empty.String
TechReport_T mappings:
TechReport_T functions:
TechReportFull_T mappings:
TechReportFull_T functions:
At this moment I get error:
Error 2 Error 3032: Problem in mapping fragments starting at line 3754:Condition member 'TRP_TechReport_T.TRP_XML' with a condition other than 'IsNull=False' is mapped. Either remove the condition on TRP_TechReport_T.TRP_XML or remove it from the mapping.
The column is not nullable in the database and mustn't be.
I can hard-set XML property to nullable, but in the case of the model updating from the database information will be lost.
At the moment it's the only thing I could think of.