How to generate ORM.XML mapping files from annotations? - orm

At work, we design solutions for rather big entities in the financial services area, and we prefer to have our deployment mappings in XML, since it's easy to change without having to recompile.
We would like to do our development using annotations and generate from them the orm.xml mapping files. I found this proof of concept annotation processor, and something like that is what I'm looking for, but something that has support for most JPA annotations.
We're using WebSphere for development so we would prefer something that considers the OpenJPA implementation

Here is a possible approach:
use the annotated classes to generate the database schema
use OpenJPA's SchemaTool to reverse engineer the database schema into their XML schema file
use OpenJPA's ReverseMappingTool to generate XML mapping files from the XML schema file

Related

How to graphically represent and manipulate apache avro schema

I have been working with apache avro lately, where i was writing the avro schema files by myself, now i am dealing with other developers schema and looking for a tool to visualize the schema to save me sometime, and it would be better if this tool also capable of manipulating the schema. My question is there are any tools that server my need?
I don't have the rep to comment, so leaving this as an answer: This isn't a visualization tool, but if you're dealing with multiple schemata, I highly recommend writing protocol files (Avro IDL) instead of writing schemata directly. They're much easier to read, and each protocol file can compile down to multiple schema files.
As it can tersely define multiple schema files, it might make it easier to grok dependencies without needing a viewer.

mule DataMapper vs groovy or similar

Is there any best practice on when to use Datamapper vs Groovy transformers etc when performing transformations or mappings in Mule?
For example I need to transform xml to json etc. I can do this nicely with Groovy using the XML builders and Json builders and its open source etc. It requires me to write some code though.
Where as Datamapper is EE only and seems a lot more opaque being a visual drag and drop.
Are there any downsides to not using DataMapper?
As you said data mapper is a graphical building tool. As pros:
Easier to maintain
User don't need any special programing skill
Support for data sense in studio
But as you said there is nothing that you can not do either with groovy or a java component.
Yes, Datamapper are for enterprise edition, but there are following advantages :-
1. Extraction and loading of flat and structured data formats
2. Filtering, extraction and transformation of input data using XPath and powerful scripting
3. Augmenting data with input parameters and lookups from other data sources
Live design-time previews of transformation results
4. It definitely has high-performance, scalable data mapping operations
Full reference :- https://developer.mulesoft.com/docs/display/current/Datamapper+User+Guide+and+Reference
Only issue I see in Datamapper is you need to maintain the mapping files.
But for the community edition user, they need to find other options in transforming and mapping .
In that case as you said, they might use their custom Java classes, Groovy component, expression component etc.

Is there a SQL information_schema XSD definition?

In SQL:2008, and also previous standards, the INFORMATION_SCHEMA is described as the standard meta-schema. In principle, meta-data could be unloaded into XML for further processing and reverse-engineering of schema meta data with XSLT and other XML tools.
Has this been done before?
Is there a somewhat complete XSD available, that describes the INFORMATION_SCHEMA?
N.B: I'm asking this because I would like to implement unloading of a database schema into a SQL standard INFORMATION_SCHEMA XML structure in jooq-meta, and then in a second process to load that schema again, to generate Java source code artefacts in jOOQ. For that, I would prefer not to roll my own XSD, but use a pre-existing as-close-to-the-standard-as-possible XSD
ANSI/ISO have not defined a particular way of representing a database schema using XML.
The latest standard is SQL:2011.
Here you can see the list of official standards. But, as you can see, they're not free:
35.060: Languages used in information technology
Look for ISO/IEC 9075-x in the list. As you can see there's still only the old INFORMATION SCHEMA.
So, your only option is to look for something widely used. Altova has its own way of doing this (a function named "Create XML Schema from DB Structure"). Look at this link:
How to Convert a Database to an XML Schema
This application has also options to create the database from the exported schema.
I think this is the closest to an standard that you can find (Altova is one of the leading XML software companies. If there was some kind of standard they should know it and use it).
Oxygen XML has also its own way of doing this, and it lloks like there is some kind of "IOS draft":
Extract XML Schema From a Database Structure

NHibernate Database-First

I'm putting a front-end together for one of our databases and would like to use NHibernate for it.
Can anyone point out any resources for getting started with Database-first approach? Most tutorials I've seen are for Code/Entity First.
ASP.NET MVC 3 will be my environment, if it matters.
Thanks.
It is all about configuring with NHibernate. As long as Nhibernate is concern, it will not create a database if that is not exists. So you have to configure Nhibernate with the connection string of your existing database in hibernate.cfg.xml(You can also use loquacious api)
There are lots of configuration possibility in NHibernate; Example includes ConfORM, FluentNhibernate, Configuring With Code, XML.
For existing database going with xml is often easy. If you choose xml, you can use tools like myGeneration to generate mappings for you.
As long as you map your object correctly with the existing database nibernate will not complain whether you create your database first or code first. So any intorductory example/application/resource that uses nhibernate as an orm mapper should serve as getting started for you.
Still there are some techniques you can follow to do database first modeling. Here is a link that may help(code example) Effective Techniques for Database-Driven Modeling
Here is the Screen Cast Explaining the techniques
please take a look at this: http://www.devart.com/entitydeveloper/nhibernate-designer.html it is not a freeware.
There is another open source tool which was referred in another question long time back. here is the link: http://www.mygenerationsoftware.com/phpBB2/viewtopic.php?t=1505
btw are you planning to use fluent nhibenrate or just nhibernate?
On a side note: Entity Framework supports a database-first approach with an integrated designer for Visual Studio. This designer produces an XML file (EDMX) that describes the required mappings.
Note: I am not marketing any of these products.

Is there an XML language for defining/authoring SQL database schemas?

Is there a dialect of XML for defining the tables, indexes and relations of a relational database, and a "compiler" or stylesheet to transform that definition into SQL CREATE statements (DDL)?
EG, something that might look like:
<Table Name="orders">
<Column Name="order_id" Type="varchar" Size="20"/>
... etc ...
</Table>
I'd like to keep the configuration of a service and its dependencies all in one place, and XML is looking like the best choice because of its wide support and its ability to mix namespaces. With it, I could write an installation program that can install this service and create the database, its tables, indexes, relations, etc. without being tied to a specific SQL implementation.
Edit: This has nothing to do with ORM.
Something like xml2ddl?
Sounds like XML based migrations, never seen one though.
If you're into OR/M you could take a look at (N)Hibernate's hbm2ddl tool. It generates the appropriate create commands for the schema on various database dialects out of an XML definition.
I've written my own a couple of times for different projects. If you're good at XSLT, knowledgeable about DDL, and have a good development environment, it's surprisingly easy (like, 2 or 3 hours work) to hack together a schema for representing metadata and a transform that produces your database-creation script.
This has all the usual advantages and disadvantages of doing it yourself: on the one hand, you control the feature set, but on the other hand, you're responsible for the feature set. In my projects, the feature set was small enough that it was easier to build it myself than it would have been to learn how to work with someone else's application framework.