Spring tries to validate xml confniguration files against xml schemas. Which is fine, but there might be cases when the validation fails (outdated schema, for example). Is there a way to turn off xsd validation?
See this Spring JIRA: https://jira.spring.io/browse/SPR-5014 - has both the team's comments on why they won't directly build it in as well as an example of how to implement yourself.
Related
Is there a tool, which can convert Spring xml configs to java configs? I have a lot of large xml configs and don't want to convert in manually.
Nope, but it's something you could write. I can see Spring config moving exclusively to it's Java form soon, so it might not be needed in the future.
Check this book out, the third chapter has some examples on how to do this.
http://www.gocit.vn/files/Spring.in.Action.3rd.Edition-www.gocit.vn.pdf
I am using jaxb to autogenerate java classes from an xsd file. I will need to persist the data that will be stored in the objects that will be instantiated from the classes. Is there some way that the hibernate code can be autogenerated in the same classes that are autogenerated by JAXB?
I will need to regenerate the classes many times in the course of development. If I have to write the hibernate code by hand, the only reasonable method I can imagine is to write separate classes with hibernate for persistence, and to write connector classes that migrate the autogenerated classes into the persistence classes. Otherwise, my hand-written hibernate code would be over-written every time I re-run jaxb based on fine tuning of the xsd file. If hibernate code were also autogenerated, I could end up using a lot fewer classes.
Hyperjaxb3 is the way to go. It is a JAXB plugin that you include in the build process. When you run your xsd file through xjc, you will not only get xml-related annotations on the generated classes, you will also get JPA annotations. Without writing hardly any code, you will be able to take an XML document, persist it to a database, query the document from the database and get XML text back out. The generated code can be customized either in the xsd file or in an associated binding file (just like with vanilla xjc). We also utilize hbm2ddl on the produced classes to configure hibernate.
We have been actively using this on several schemas for the past couple of years.
As you edit your XML schema/bindings (and thus your DB schema), you will have to manually write a SQL migration script to upgrade any existing databases. It seems like most DBMS have a schema comparison tool that can be leveraged here. We automatically compare the freshly created schema to the migrated (from a baseline) schema on every build.
I need to validate some xml files in the resources of an Android application against an XML Schema. Although there is an available API to create instances of SchemaFactory, there seems to be no implementation for XML Schema, as stated by the answers to these questions: 1, 2 and 3.
Are there any good and lightweight libraries to provide that functionality in the Android platform?
Try Lycia. Its around 270 kb. Here is nice step by step example for schema validation. It creates a schema, a small XML referring to schema (via schemaLocation) and then an example to parse the xml with schema validation
we want to do business rule validation outside our java code using some xml etc.we are using Spring 3.1 and JSF 2.0.i tried to search but cudn't found concrete on placing business rule outside our java code.i will thankful if someone can provide direaction for this
I know this isn't exactly what you are looking for but you can use Hibernate annotations in place of hard coded validators in JSF 2.
These are just a few examples of this.
http://weblogs.java.net/blog/urubatan/archive/2006/09/aspectj_hiberna.html
http://docs.jboss.org/seam/1.1GA/reference/en/html/validation.html
I am using openjpa runtime of JPA specification.
At development time I am using annotations to configure jpa entities.
At Integration, Pre-Production and and Production environment, I am using orm mapping files to configure entities. Please suggest a tool which can generate mapping files from jpa annotations, so that these mapping files can be manually edited for different environment.
If there is already a opensource maven-plugin; will be great.
I don't really know OpenJPA so there is maybe a better way to do this but one option would be to first generate the XML schema file from annotated entities using the Schema Tool and then the orm.xml file from the schema.xml using the Reverse Mapping Tool. Actually, this process is discussed in this thread.
I've checked the OpenJPA Maven Plugin but it doesn't seem to support the Reverse Mapping part (it only has a openjpa:schema goal that allows to Create a file which contains the schema mapping XML, the first required operation, but nothing for the second part). Extending the plugin to add the missing openjpa:reverse-mapping goal would thus require some development but it shouldn't be an hard task.
There is another option though. OpenJPA provides the following Ant tasks for both operations:
org.apache.openjpa.jdbc.ant.ReverseMappingToolTask
org.apache.openjpa.jdbc.ant.SchemaToolTask
So it should be possible to call them from Maven using the Maven AntRun Plugin. Check the documentation for more details on how to use them.