}
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.doit.dagama.domain.Home;
import com.doit.dagama.repo.impl.BaseDAOImpl;
import com.doit.dagama.svr.HomeService;
@Service
@Transactional
public class HomeServiceImpl extends BaseDAOImpl<Home> implements HomeService {
public Home getHomeById(long Id) {
return this.em.find(Home.class, Id);
}
}
//home.java
package com.doit.dagama.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity(name = "home")
public class Home {
private long Id;
private String Title;
private String Theme;
private Integer Count;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public long getId() {
return Id;
}
public void setId(long id) {
Id = id;
}
public String getTitle() {
return Title;
}
public void setTitle(String title) {
Title = title;
}
public String getTheme() {
return Theme;
}
public void setTheme(String theme) {
Theme = theme;
}
public Integer getCount() {
return Count;
}
public void setCount(Integer count) {
Count = count;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return "Title: "+ Title +" " + "Theme: "+Theme + " Count: "+ Count;
}
}
CREATE TABLE home(
Id INT(4) not null auto_increment,
Title VARCHAR(100),
Theme VARCHAR(100),
Count INT(4),
primary key(Id)
)ENGINE=InnoDB DEFAULT CHARSET=UTF8;
INSERT INTO home (Title,Theme,Count) VALUES('lianji',N'yuu',49);
INSERT INTO home (Title,Theme,Count) VALUES('shengtun',N'uyyu',9);
INSERT INTO home (Title,Theme,Count) VALUES('laoli','太阳',149);
INSERT INTO home (Title,Theme,Count) VALUES(N'yuyu',N'yuyuy',499);
INSERT INTO home (Title,Theme,Count) VALUES('what','createe',88);
INSERT INTO home (Title,Theme,Count) VALUES('retetss',N'yuf',582);
INSERT INTO home (Title,Theme,Count) VALUES('falali',N'eseddz',490);
INSERT INTO home (Title,Theme,Count) VALUES(N'dfddf',N'rtrt',449);
INSERT INTO home (Title,Theme,Count) VALUES(N'dfdfd',N'dfdtrd',249);
INSERT INTO home (Title,Theme,Count) VALUES('科考队','太阳',19);