May 31 2013 by Kevin Bowersox

The following tutorial details how to use the Spring Data to query against an object model. The tutorial explains how to define various interface methods on Spring Data Repositories that account for specific criteria and ordering. To follow along download the base code used for this tutorial from this Git Hub Repository. Source code for the completed project can be downloaded by clicking the GitHub logo below.

Continue Reading
May 03 2013 by Kevin Bowersox

While configuring an upcoming project I experienced an issue that was caused by a conflict between Spring MVC and Spring Data.  My pom.xml file contained the following dependencies:

  <dependencies>
  	<dependency>
  		<groupId>org.springframework</groupId>
  		<artifactId>spring-webmvc</artifactId>
  		<version>3.2.2.RELEASE</version>
  	</dependency>
  	<dependency>
  		<groupId>org.springframework.data</groupId>
  		<artifactId>spring-data-jpa</artifactId>
  		<version>1.3.0.RELEASE</version>
  	</dependency>
  </dependencies

This caused the following exception to be thrown when I ran the application:

Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2904)
	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2904)
	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
	at org.springframework.core.type.classreading.SimpleMetadataReader.(SimpleMetadataReader.java:63)
	at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
	at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
	at org.springfr

 

After some investigation I learned that the exception was thrown due to a conflict between the version of Spring AOP used by the two projects.

To resolve the issue, I accessed the Dependency Hierarchy in the pom.xml file and located the spring-aop:3.2.2.RELEASE dependency.  I then right clicked this dependency and click Lock Transitive Dependency Version.

Continue Reading
April 12 2013 by Kevin Bowersox
 

The following tutorial details how to use JPA to persist entities that leverage an inheritance relationship using the @MappedSuperclass annotation.  It explores how the annotation is used and gives a brief overview of inheritance.  The tutorial builds off of a project created in the previous post, JPA: Ordering Collections with @OrderBy.  To follow along with this video, you can download the source code for the previous post from the GitHub Repository.  Source code for the completed project can be downloaded by clicking the GitHub logo below.

Continue Reading
April 06 2013 by Kevin Bowersox

The following tutorial details how to order a collection within an entity using the @OrderBy annotation.  It explores how the annotation is used as well as a potential issue with ordering by fields on an embedded object. The tutorial builds off of a project created in the previous post, JPA: Entity Collections.  To follow along with this video, you can download the source code for the previous post from the GitHub Repository.  Source code for the completed project can be downloaded by clicking the GitHub logo below.

Continue Reading
March 29 2013 by Kevin Bowersox

The following tutorial details how to configure an ElementCollection within an entity.  It describes "how" and "why" to use the JPA annotations @ElementCollection and @CollectionTable.  The tutorial builds off of a project created in the previous post, JPA: Embedding Embeddables within Entities.  To follow along with this video, you can download the source code for the previous post from the GitHub Repository.  Source code for the completed project can be downloaded by clicking the GitHub logo below.

Continue Reading
Next 5 Entries