forked from eugenp/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
eugenp
committed
Aug 12, 2013
1 parent
c7a1377
commit c82d342
Showing
8 changed files
with
159 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
23 changes: 23 additions & 0 deletions
23
...eptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/FooDao.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.baeldung.ex.mappingexception.cause1.persistence.dao; | ||
|
||
import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; | ||
import org.baeldung.persistence.common.AbstractHibernateDao; | ||
import org.hibernate.SessionFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public class FooDao extends AbstractHibernateDao<Foo> implements IFooDao { | ||
|
||
@Autowired | ||
private SessionFactory sessionFactory; | ||
|
||
public FooDao() { | ||
super(); | ||
|
||
setClazz(Foo.class); | ||
} | ||
|
||
// API | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
...ptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/dao/IFooDao.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.baeldung.ex.mappingexception.cause1.persistence.dao; | ||
|
||
import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; | ||
import org.baeldung.persistence.common.IOperations; | ||
|
||
public interface IFooDao extends IOperations<Foo> { | ||
// | ||
} |
81 changes: 81 additions & 0 deletions
81
...ceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.baeldung.ex.mappingexception.cause1.persistence.model; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
public class Foo implements Serializable { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private long id; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
public Foo() { | ||
super(); | ||
} | ||
|
||
public Foo(final String name) { | ||
super(); | ||
|
||
this.name = name; | ||
} | ||
|
||
// API | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(final long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(final String name) { | ||
this.name = name; | ||
} | ||
|
||
// | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((name == null) ? 0 : name.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
final Foo other = (Foo) obj; | ||
if (name == null) { | ||
if (other.name != null) | ||
return false; | ||
} else if (!name.equals(other.name)) | ||
return false; | ||
return true; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder builder = new StringBuilder(); | ||
builder.append("Foo [name=").append(name).append("]"); | ||
return builder.toString(); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/FooService.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.baeldung.ex.mappingexception.cause1.persistence.service; | ||
|
||
import org.baeldung.ex.mappingexception.cause1.persistence.dao.IFooDao; | ||
import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; | ||
import org.baeldung.persistence.common.AbstractService; | ||
import org.baeldung.persistence.common.IOperations; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class FooService extends AbstractService<Foo> implements IFooService { | ||
|
||
@Autowired | ||
private IFooDao dao; | ||
|
||
public FooService() { | ||
super(); | ||
} | ||
|
||
// API | ||
|
||
@Override | ||
protected IOperations<Foo> getDao() { | ||
return dao; | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
...rc/main/java/org/baeldung/ex/mappingexception/cause1/persistence/service/IFooService.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.baeldung.ex.mappingexception.cause1.persistence.service; | ||
|
||
import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; | ||
import org.baeldung.persistence.common.IOperations; | ||
|
||
public interface IFooService extends IOperations<Foo> { | ||
// | ||
} |
This file contains 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
This file contains 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