<repositories> ... <repository> <id>springfield-mvn-repo</id> <url>https://raw.github.com/u2ware/springfield/mvn-repo/</url> </repository> ... </repositories> <dependencies> ... <dependency> <groupId>com.u2ware</groupId> <artifactId>springfield</artifactId> <version>1.5.0</version> </dependency> ... </dependencies>
@Springfield( strategy=Strategy.JPA, entity=Class.class, identity={"...","..."}, topLevelMapping="...", methodLevelMapping={"...","..."}, attributesCSV="key1={value1},key2={value2}, ..." ) @Entity public class Foo{ @Id private String id; ... }
Table 1.1.
@Springfield
Attributes
name | required | assignable | description |
---|---|---|---|
strategy | optional |
Springfield.Strategy
| bean auto register strategy... |
entity | optional | java.lang.Class | Entity class |
identity | optional | java.lang.String[] | Identity property names |
topLevelMapping | optional | java.lang.String | Handler mapping path |
methodLevelMapping | optional | java.lang.String[] | Handler mapping path |
attributesCSV | optional | java.lang.String | view options |
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:springfield="http://www.u2ware.com/schema/springfield" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.u2ware.com/schema/springfield http://www.u2ware.com/schema/springfield/u2ware-springfield.xsd"> <springfield:modules properties-ref="...." base-package="com.yourcompany.yourproject" default-strategy="..." data-source-ref="..." entity-manager-factory-ref="..." session-factory-ref="..." sql-session-factory-ref="..." /> ... </beans>
springfield namesapce & schemaLocation |
Table 1.2. <springfield:modules> Attributes
name | required | assignable | description |
---|---|---|---|
properties-ref | optional | java.util.Properties | Properties Reference Bean Name |
base-package | required | java.lang.String | root package for scan @Springfield |
default-strategy | optional |
Springfield.Strategy
| @Springfield default bean auto register strategy |
data-source-ref | optional | javax.sql.DataSource | dataSource Reference Bean Name |
entity-manager-factory-ref | optional | org.springframework.orm.jpa.AbstractEntityManagerFactoryBean | JPA EntityManager Reference Bean Name |
session-factory-ref | optional | org.springframework.orm.hibernate3.AbstractSessionFactoryBean | Hibernate SessionFactory Reference Bean Name |
sql-session-factory-ref | optional | org.mybatis.spring.SqlSessionFactoryBean | Mybatis SessionFactory Reference Bean Name |
root-context.xml
<beans> <jdbc:embedded-database id="yourDataSource" type="HSQL"/> <springfield:modules base-package="com.yourcompany.yourproject" data-source-ref="yourDataSource" /> </beans>
Foo.java
package com.yourcompany.yourproject.foo; @Springfield @Entity public class Foo{ @Id private String name; private Integer age; ... }
Bar.java
package com.yourcompany.yourproject.bar; @Entity public class Bar{ @Id private Integer seq; ... }
BarSearch.java
package com.yourcompany.yourproject.bar; @Springfield( entity=Bar.class, topLevelMapping="/a/b/c/d" ) public class BarSearch{ ... }