This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company.app; | |
import org.springframework.context.support.GenericXmlApplicationContext; | |
import com.company.app.annotation.dao.ContactSfDao; | |
public class JdbcContactSfDaoTest { | |
public static void main(String[] args) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apress.prospring3.ch17.service; | |
import java.util.List; | |
import org.springframework.data.domain.Page; | |
import org.springframework.data.domain.Pageable; | |
import com.apress.prospring3.ch17.domain.Contact; | |
public interface ContactService { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
insert into contact (first_name, last_name, birth_date) values ('Clarence', 'Ho', '1980-07-30'); | |
insert into contact (first_name, last_name, birth_date) values ('Scott', 'Tiger', '1990-11-02'); | |
insert into contact (first_name, last_name, birth_date) values ('John', 'Smith', '1964-02-28'); | |
insert into contact (first_name, last_name, birth_date) values ('Peter', 'Jackson', '1944-1-10'); | |
insert into contact (first_name, last_name, birth_date) values ('Jacky', 'Chan', '1955-10-31'); | |
insert into contact (first_name, last_name, birth_date) values ('Susan', 'Boyle', '1970-05-06'); | |
insert into contact (first_name, last_name, birth_date) values ('Tinner', 'Turner', '1967-04-30'); | |
insert into contact (first_name, last_name, birth_date) values ('Lotus', 'Notes', '1990-02-28'); | |
insert into contact (first_name, last_name, birth_date) values ('Henry', 'Dickson', '1997-06-30'); | |
insert into contact (first_name, last_name, birth_date) values ('Sam', 'Davis', '2001-01-31'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS CONTACT; | |
CREATE TABLE CONTACT ( | |
ID INT NOT NULL AUTO_INCREMENT | |
, FIRST_NAME VARCHAR(60) NOT NULL | |
, LAST_NAME VARCHAR(40) NOT NULL | |
, BIRTH_DATE DATE | |
, DESCRIPTION VARCHAR(2000) | |
, PHOTO BLOB | |
, VERSION INT NOT NULL DEFAULT 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final class ContactMapper implements RowMapper<Contact> { | |
public Contact mapRow(ResultSet rs, int rowNum) throws SQLException { | |
Contact contact = new Contact(); | |
contact.setId(rs.getLong("id")); | |
contact.setFirstName(rs.getString("first_name")); | |
contact.setLastName(rs.getString("last_name")); | |
contact.setBirthDate(rs.getDate("birth_date")); | |
return contact; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
<dependency> | |
<groupId>org.hibernate</groupId> | |
<artifactId>hibernate-entitymanager</artifactId> | |
<version>3.6.8.Final</version> | |
</dependency> | |
<dependency> | |
<groupId>javax.validation</groupId> | |
<artifactId>validation-api</artifactId> | |
<version>1.0.0.GA</version> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created on Oct 12, 2011 | |
*/ | |
package com.company.app.domain; | |
import java.io.Serializable; | |
import java.util.HashSet; | |
import java.util.Set; | |
import javax.persistence.Column; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created on Oct 12, 2011 | |
*/ | |
package com.company.app.domain; | |
import static javax.persistence.GenerationType.IDENTITY; | |
import java.io.Serializable; | |
import javax.persistence.Column; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created on Oct 12, 2011 | |
*/ | |
package com.company.app.domain; | |
import java.io.Serializable; | |
import java.util.Date; | |
import java.util.HashSet; | |
import java.util.Set; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company.hibernate; | |
import java.util.Date; | |
import java.util.List; | |
import java.util.Set; | |
import org.springframework.context.support.GenericXmlApplicationContext; | |
import com.company.hibernate.dao.ContactDao; | |
import com.company.hibernate.domain.Contact; |