-Discussion on Java Persistence Framework for 2017 (1) -Consideration of 2017 Java Persistence Framework (2) Doma2
Since I am writing using the gap time, I would appreciate it if you could point out any parts with poor accuracy. First, exclude those that are EOL. We will consider paid functions, but we will not actually use them, due to the problem of pockets. The DB used is fixed to Postgre for a stupid reason such as "Well, maybe Postgre can be used even if it is not specified."
** Operation has not been confirmed due to network environment problems. ** ** Please note that neither gradle nor maven can connect to the repository and it does not work, so it is a guess article ... You should be able to hit Mithra Generator with ant, but this is troublesome ...
ORM | Transaction | Data Model | DSL |
---|---|---|---|
○ | ※1 | ※2 | ○ |
○: Correspondence ×: Not supported
――A feeling of "definition from convention" --A configuration that produces everything from XML, table DDL and even index DDL are generated depending on the definition of XML --Sign of lazy evaluation felt from DSL --Supports temporal data model and bitemporal data model, but does not need to be used --Since it is SQL generation from DSL, the user needs to be familiar with the behavior. --Overall, it looks like a DSL with the purpose of "producing highly systematic content under a clear common understanding."
EmployeeSearchTest.java
//Primary key search
MithraManagerProvider.getMithraManager().executeTransactionalCommand(tx -> {
Employee employee = EmployeeFinder.findOne(EmployeeFineder.id().eq(BigDecimal.ZERO));
});
//Search all
MithraManagerProvider.getMithraManager().executeTransactionalCommand(tx -> {
EmployeeList list = new EmployeeList(EmployeeFiner.all());
});
Employee.xml
<MithraObject
objectType="transactional"
xmlns:xsi="http://www.w3.org/2001/XML-Schema-instance"
xsi:noNamespaceSchemaLocation="mithraobject.xsd">
<PackageName>jp.co.qualsyite.</PackageName>
<ClassName>Employee</ClassName>
<DefaultTable>employee</DefaultTable>
<Attribute
name="id"
javaType="java.util.BigDecimal"
columnName="id"
primaryKey="true"
primaryKeyGeneratorStrategy="SimulatedSequence">
<SimulatedSequence
sequenceName="employee"
sequenceObjectFactoryName="jp.co.qualysite.ObjectSequenceFactory"
hasSourceAttribute="false"
batchSize="1"
initialValue="0"
incrementSize="1"/>
</Attribute>
<Attribute name="firstName" javaType="java.lang.String" columnName="first_name" nullable="false" maxLength="60" />
<Attribute name="middleName" javaType="java.lang.String" columnName="middle_name" nullable="false" maxLength="60" />
<Attribute name="lastName" javaType="java.lang.String" columnName="last_name" nullable="false" maxLength="60" />
<Attribute name="from" javaType="java.util.Date" columnName="from" nullable="false" />
<Attribute name="thru" javaType="java.util.Date" columnName="thru" nullable="false" />
<Attribute name="in" javaType="java.util.Date" columnName="in" nullable="false" />
<Attribute name="out" javaType="java.util.Date" columnName="out" nullable="false" />
<Relationship
name="posts"
relatedObject="Post"
cardinality="one-to-many">
this.id = Post.employeeId
</Relationship>
</MithraObject>
--Cover range is ORM + data model logic --Since DSL is a Java implementation, the complementary function of the IDE works. ――It is strong because there is no need to reinvent the wheel on the data model side. ――It seems that the structure needs to be solid with the system in order to harden it with XML.
I'm addicted to it or it's not working.
-Discussion on Java Persistence Framework for 2017 (4) jOOQ
Recommended Posts