org.springframework.test.context.junit4.orm.domain.Person Java Examples

The following examples show how to use org.springframework.test.context.junit4.orm.domain.Person. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HibernateSessionFlushingTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void findSam() {
	Person sam = personService.findByName(SAM);
	assertNotNull("Should be able to find Sam", sam);
	DriversLicense driversLicense = sam.getDriversLicense();
	assertNotNull("Sam's driver's license should not be null", driversLicense);
	assertEquals("Verifying Sam's driver's license number", Long.valueOf(1234), driversLicense.getNumber());
}
 
Example #2
Source File: HibernateSessionFlushingTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void saveJuergenWithDriversLicense() {
	DriversLicense driversLicense = new DriversLicense(2L, 2222L);
	Person juergen = new Person(JUERGEN, driversLicense);
	int numRows = countRowsInPersonTable();
	personService.save(juergen);
	assertPersonCount(numRows + 1);
	assertNotNull("Should be able to save and retrieve Juergen", personService.findByName(JUERGEN));
	assertNotNull("Juergen's ID should have been set", juergen.getId());
}
 
Example #3
Source File: HibernateSessionFlushingTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void findSam() {
	Person sam = personService.findByName(SAM);
	assertNotNull("Should be able to find Sam", sam);
	DriversLicense driversLicense = sam.getDriversLicense();
	assertNotNull("Sam's driver's license should not be null", driversLicense);
	assertEquals("Verifying Sam's driver's license number", new Long(1234), driversLicense.getNumber());
}
 
Example #4
Source File: HibernateSessionFlushingTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test  // SPR-16956
@Transactional(readOnly = true)
public void findSamWithReadOnlySession() {
	Person sam = personService.findByName(SAM);
	sam.setName("Vlad");
	// By setting setDefaultReadOnly(true), the user can no longer modify any entity...
	Session session = sessionFactory.getCurrentSession();
	session.flush();
	session.refresh(sam);
	assertEquals("Sam", sam.getName());
}
 
Example #5
Source File: HibernateSessionFlushingTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void saveJuergenWithDriversLicense() {
	DriversLicense driversLicense = new DriversLicense(2L, 2222L);
	Person juergen = new Person(JUERGEN, driversLicense);
	int numRows = countRowsInTable("person");
	personService.save(juergen);
	assertEquals("Verifying number of rows in the 'person' table.", numRows + 1, countRowsInTable("person"));
	assertNotNull("Should be able to save and retrieve Juergen", personService.findByName(JUERGEN));
	assertNotNull("Juergen's ID should have been set", juergen.getId());
}
 
Example #6
Source File: HibernateSessionFlushingTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void findSam() {
	Person sam = personService.findByName(SAM);
	assertNotNull("Should be able to find Sam", sam);
	DriversLicense driversLicense = sam.getDriversLicense();
	assertNotNull("Sam's driver's license should not be null", driversLicense);
	assertEquals("Verifying Sam's driver's license number", Long.valueOf(1234), driversLicense.getNumber());
}
 
Example #7
Source File: HibernateSessionFlushingTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test  // SPR-16956
@Transactional(readOnly = true)
public void findSamWithReadOnlySession() {
	Person sam = personService.findByName(SAM);
	sam.setName("Vlad");
	// By setting setDefaultReadOnly(true), the user can no longer modify any entity...
	Session session = sessionFactory.getCurrentSession();
	session.flush();
	session.refresh(sam);
	assertEquals("Sam", sam.getName());
}
 
Example #8
Source File: HibernateSessionFlushingTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void saveJuergenWithDriversLicense() {
	DriversLicense driversLicense = new DriversLicense(2L, 2222L);
	Person juergen = new Person(JUERGEN, driversLicense);
	int numRows = countRowsInTable("person");
	personService.save(juergen);
	assertEquals("Verifying number of rows in the 'person' table.", numRows + 1, countRowsInTable("person"));
	assertNotNull("Should be able to save and retrieve Juergen", personService.findByName(JUERGEN));
	assertNotNull("Juergen's ID should have been set", juergen.getId());
}
 
Example #9
Source File: StandardPersonService.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
@Transactional(readOnly = false)
public Person save(Person person) {
	return this.personRepository.save(person);
}
 
Example #10
Source File: StandardPersonService.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public Person findByName(String name) {
	return this.personRepository.findByName(name);
}
 
Example #11
Source File: HibernateSessionFlushingTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test(expected = ConstraintViolationException.class)
public void saveJuergenWithNullDriversLicense() {
	personService.save(new Person(JUERGEN));
}
 
Example #12
Source File: HibernateSessionFlushingTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
private void updateSamWithNullDriversLicense() {
	Person sam = personService.findByName(SAM);
	assertNotNull("Should be able to find Sam", sam);
	sam.setDriversLicense(null);
	personService.save(sam);
}
 
Example #13
Source File: HibernatePersonRepository.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public Person save(Person person) {
	this.sessionFactory.getCurrentSession().save(person);
	return person;
}
 
Example #14
Source File: HibernatePersonRepository.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public Person findByName(String name) {
	return (Person) this.sessionFactory.getCurrentSession().createQuery(
		"from Person person where person.name = :name").setString("name", name).uniqueResult();
}
 
Example #15
Source File: StandardPersonService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public Person findByName(String name) {
	return this.personRepository.findByName(name);
}
 
Example #16
Source File: StandardPersonService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@Transactional(readOnly = false)
public Person save(Person person) {
	return this.personRepository.save(person);
}
 
Example #17
Source File: HibernateSessionFlushingTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test(expected = ConstraintViolationException.class)
public void saveJuergenWithNullDriversLicense() {
	personService.save(new Person(JUERGEN));
}
 
Example #18
Source File: HibernateSessionFlushingTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private void updateSamWithNullDriversLicense() {
	Person sam = personService.findByName(SAM);
	assertNotNull("Should be able to find Sam", sam);
	sam.setDriversLicense(null);
	personService.save(sam);
}
 
Example #19
Source File: HibernatePersonRepository.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public Person save(Person person) {
	this.sessionFactory.getCurrentSession().save(person);
	return person;
}
 
Example #20
Source File: HibernatePersonRepository.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public Person findByName(String name) {
	return (Person) this.sessionFactory.getCurrentSession().createQuery(
		"from Person person where person.name = :name").setParameter("name", name).getSingleResult();
}
 
Example #21
Source File: HibernatePersonRepository.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public Person save(Person person) {
	this.sessionFactory.getCurrentSession().save(person);
	return person;
}
 
Example #22
Source File: HibernatePersonRepository.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public Person findByName(String name) {
	return (Person) this.sessionFactory.getCurrentSession().createQuery(
		"from Person person where person.name = :name").setParameter("name", name).getSingleResult();
}
 
Example #23
Source File: HibernateSessionFlushingTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private void updateSamWithNullDriversLicense() {
	Person sam = personService.findByName(SAM);
	assertNotNull("Should be able to find Sam", sam);
	sam.setDriversLicense(null);
	personService.save(sam);
}
 
Example #24
Source File: StandardPersonService.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public Person findByName(String name) {
	return this.personRepository.findByName(name);
}
 
Example #25
Source File: HibernateSessionFlushingTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test(expected = ConstraintViolationException.class)
public void saveJuergenWithNullDriversLicense() {
	personService.save(new Person(JUERGEN));
}
 
Example #26
Source File: StandardPersonService.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
@Transactional(readOnly = false)
public Person save(Person person) {
	return this.personRepository.save(person);
}
 
Example #27
Source File: PersonRepository.java    From spring-analysis-note with MIT License votes vote down vote up
Person save(Person person); 
Example #28
Source File: PersonService.java    From java-technology-stack with MIT License votes vote down vote up
Person save(Person person); 
Example #29
Source File: PersonService.java    From spring-analysis-note with MIT License votes vote down vote up
Person findByName(String name); 
Example #30
Source File: PersonService.java    From spring-analysis-note with MIT License votes vote down vote up
Person save(Person person);