java - What sort of database will I get with an Apache Wicket Application? -


so i've done object oriented design, put database schema go design, , promised impossibly short deadline delivery i've decided make life "easier" using web framework.

spring seems insanely complicated (and rather inelegant @ superficial glance) , roo impossible understand and/or on forums beyond doing beyond basic crud app.

i using (and learning!) wicket accomplish task. spending lot of time trying figure out how wicket creates , uses database , if understand correctly automagically pojos creating. creating objects use objects in moderately complex ways, however, , have better idea of end result going in mysql.

does have information or links explain resulting schema looks wicket application?

it seems me coming php or .net world , not used way things work in java (with emphasis on work). in short: there no free lunch , if glance @ spring or roo , conclude these complicated, might have rough times ahead. java offers lot of frameworks , flexibility, have work.

that said, love wicket although have of learning curve. wicket has great approach templating , resolving business , control logic in actual java code. also, wicket has active community extensive documentation, wiki's , examples. wicket does, joril pointed out, not related object relational mapping (orm) or persistence in general afaik. there might extensions or wicket-related projects offer this.

here advice on how tackle this: use maven2 , spring (yes, spring) , import following dependencies in pom.xml:

<properties>     <spring.version>3.0.0.release</spring.version>     <wicket.version>1.4.10</wicket.version> </properties>  <dependencymanagement> <dependency>     <groupid>org.springframework</groupid>     <artifactid>org.springframework.context</artifactid>     <version>${spring.version}</version> </dependency> <dependency>     <groupid>org.springframework</groupid>     <artifactid>org.springframework.orm</artifactid>     <version>${spring.version}</version> </dependency> <dependency>     <groupid>org.apache.commons</groupid>     <artifactid>com.springsource.org.apache.commons.dbcp</artifactid>     <version>1.2.2.osgi</version>     <scope>runtime</scope> </dependency> <dependency>     <groupid>org.apache.commons</groupid>     <artifactid>com.springsource.org.apache.commons.pool</artifactid>     <version>1.5.3</version>     <scope>runtime</scope> </dependency> <dependency> <groupid>com.mysql.jdbc</groupid>     <artifactid>com.springsource.com.mysql.jdbc</artifactid>     <version>5.1.6</version> </dependency> <dependency>     <groupid>org.hibernate</groupid>     <artifactid>com.springsource.org.hibernate</artifactid>     <version>3.3.2.ga</version> </dependency> <dependency>     <groupid>javax.persistence</groupid>     <artifactid>com.springsource.javax.persistence</artifactid>     <version>1.0.0</version> </dependency> <dependency>     <groupid>org.hibernate</groupid>     <artifactid>com.springsource.org.hibernate.annotations</artifactid>     <version>3.4.0.ga</version>     <exclusions>         <exclusion>         <groupid>org.apache.commons</groupid>         <artifactid>com.springsource.org.apache.commons.logging</artifactid>     </exclusion>     </exclusions> </dependency> <dependency>     <groupid>org.apache.wicket</groupid>     <artifactid>wicket</artifactid>     <version>${wicket.version}</version> </dependency> <dependency>     <groupid>org.apache.wicket</groupid>     <artifactid>wicket-spring</artifactid>     <version>${wicket.version}</version>     <exclusions>         <exclusion>         <artifactid>spring</artifactid>         <groupid>org.springframework</groupid>     </exclusion>     </exclusions> </dependency> <dependency>     <groupid>org.apache.wicket</groupid>     <artifactid>wicket-extensions</artifactid>     <version>${wicket.version}</version> </dependency> 

annotate model classes jpa/hibernate annotations (just example shows several common constructs):

@entity(name = "user") @table(name = "users", uniqueconstraints = { @uniqueconstraint(columnnames = { "email" }) }) @secondarytable(name = "user_picture") public class user implements serializable {      @id     @generatedvalue(strategy = generationtype.auto)     private long id;     private string email;     private string name;     private string password;     @lob     @column(table = "users_picture", length = 524288)     private byte[] picture;     private date birthdate;     private string phonenumber;     @manytoone(fetch = fetchtype.eager)     private address homeaddress;     @enumerated(enumtype.string)     private gender gender;       @collectionofelements(fetch = fetchtype.eager)     @enumerated(enumtype.string)     private set<weekday> workdays = new hashset<weekday>(); 

use hibernate3-maven-plugin generate database annotated model classes. huge time saver. database gets generated during test phase of maven2. there other plugins (dbunit) fill database test data or (you can use old school .sql scripts well). if change in model, change automatically propagates database (after maven build of course) great during development.

add pom (i prefer making multi-module maven project modules frontend, backend , api; go backend pom):

<build> <plugins> <plugin>     <groupid>org.codehaus.mojo</groupid>     <artifactid>hibernate3-maven-plugin</artifactid>     <version>2.0-alpha-1</version>     <configuration>         <components>             <component>             <name>hbm2ddl</name>             <implementation>                 annotationconfiguration                 </implementation>         </component>         </components>         <componentproperties>             <drop>true</drop>         <jdk5>true</jdk5>         <propertyfile>             target/classes/jdbc.properties             </propertyfile>         <skip>${maven.test.skip}</skip>         </componentproperties>         </configuration>         <executions>             <execution>             <phase>process-test-resources</phase>                 <goals>                 <goal>hbm2ddl</goal>             </goals>             </execution>          </executions>          <dependencies>              <dependency>              <groupid>mysql</groupid>                  <artifactid>mysql-connector-java</artifactid>                  <version>5.0.5</version>          </dependency>          </dependencies>     </plugin> </plugins> 

this generated table like:

+--------------------------------+--------------+------+-----+---------+----------------+ | field                          | type         | null | key | default |          | +--------------------------------+--------------+------+-----+---------+----------------+ | id                             | bigint(20)   | no   | pri | null    | auto_increment | | email                          | varchar(255) | yes  | uni | null    |                | | name                           | varchar(255) | yes  |     | null    |                | | password                       | varchar(255) | yes  |     | null    |                | | birthdate                      | datetime     | yes  |     | null    |                | | phonenumber                    | varchar(255) | yes  |     | null    |                | | gender                         | varchar(255) | yes  |     | null    |                | | address                        | bigint(20)   | yes  | mul | null    |                | +--------------------------------+--------------+------+-----+---------+----------------+ 

(users_workdays , users_picture secondary tables referring entity)

all examples based on use of mysql database; can replace with old rdbms.

i hope helps a) wake , smell ashes, b) wicket project speed orm-wise

cheers!


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -