WEB开发网
开发学院图形图像Flash 基于flex4技术从零开发flex博客系统: 7 Using JPA... 阅读

基于flex4技术从零开发flex博客系统: 7 Using JPA

 2009-05-05 12:06:09 来源:WEB开发网   
核心提示: 其中persistence-unit的name在实例化EntityManagerFactory时会用到,在sban.flexblog.managers目录下,基于flex4技术从零开发flex博客系统: 7 Using JPA(2),添加类EMFactory:packagesban.fle

其中persistence-unit的name在实例化EntityManagerFactory时会用到。

在sban.flexblog.managers目录下,添加类EMFactory:

package sban.flexblog.managers;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public final class EMFactory {
        private static EntityManagerFactory _instance = Persistence
                        .createEntityManagerFactory("transactions-optional");

        private EMFactory() {
        }

        public static EntityManagerFactory getInstance() {
                return _instance;
        }

}

该类用于返回EntityManagerFactory一个实例,其中参数”transactions-optional”为上文中定义。

在sban.flexblog目录下添加实体类GreetingEntity:

package sban.flexblog;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class GreetingEntity {

        public GreetingEntity(String user, String content, Date date)
        {
                this.user = user;
                this.greetingContent=content;
                this.date = date;
        }
        
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Long id;
        
        private String user;
        
        private String greetingContent;
        
        private Date date;
        
        public Long getId()
        {
                return this.id;
        }
        
        public String getGreetingContent()
        {
                return this.greetingContent;
        }
        
        public void setGreetingContent(String v)
        {
                this.greetingContent = v;
        }
        
        public Date getDate()
        {
                return this.date;
        }
}

上一页  1 2 3 4 5  下一页

Tags:基于 flex 技术

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接