简体   繁体   English

使用Glassfish和mysql数据库在Myeclipse中的EJB项目中使用Hibernate ORM

[英]using Hibernate ORM in an EJB Project in Myeclipse with glassfish and mysql data base

I am new to J2EE development and its frameworks, so I'm leads to create a J2EE application usign Myeclipse,glassfish ans mysql as SGBD ... I need to create a project EJB3 session I have to use Hibernate3 ORM .. My concern is that I've worked with hibernate but in a web project type and not EJB and I really do not know how my project should be like .. I just need to understand the structure of my EJB project because normally we have 2 basic classes: EJBService and EJBserviceRemote .. EJBService, containing all my methods that I would need to call from my client (a web project for exemple) and EJBServiceRemote which contains the signature of each method .. so where do I rank the DAO classes generated by Hibernate ORM and how to call them?? 我是J2EE开发及其框架的新手,所以我带领我创建一个J2EE应用程序,使用Myeclipse,glassfish和mysql作为SGBD...。我需要创建一个项目EJB3会话,我必须使用Hibernate3 ORM。我曾经使用过Hibernate,但是使用的是Web项目类型,而不是EJB,我真的不知道我的项目应该是什么样。.我只需要了解我的EJB项目的结构,因为通常我们有2个基本类:EJBService和EJBserviceRemote .. EJBService,包含我需要从客户端(例如,一个Web项目)调用的所有方法,而EJBServiceRemote包含每个方法的签名..因此,我应该在哪里对Hibernate ORM和怎么称呼他们? shoukd I copy their code in EJBService and then declare in EJBServiceRemote to be able to call them by my client?? 应该将它们的代码复制到EJBService中,然后在EJBServiceRemote中声明以便能够由我的客户端调用它们?

SOS I'm really disturbed 我真的很不高兴

Caused by: java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion 造成原因:java.lang.NoClassDefFoundError:org / hibernate / criterion / Criterion

may be you're missing one of the hibernate jars (hibernate-core.jar) or maybe you have an older version of hibernate + a recent one at the same time in your classpath. 可能是您丢失了一个休眠jar(hibernate-core.jar),或者您的类路径中同时有一个较旧的hibernate版本和一个最新版本。

add all the jars that you're using in your ejb project to the following glassfish directory : 将您在ejb项目中使用的所有jar添加到以下glassfish目录中:

  1. C:/..../glassfish/lib C:/..../ glassfish / lib
  2. C:/..../glassfish/domains/"your domain name"/lib C:/..../ glassfish / domains /“您的域名” / lib

ok everything is working now here is my methode to show data: 好的,现在一切正常,这是我显示数据的方法:

@SuppressWarnings("unchecked")
  public int[][] afficheProduitsStockList(){

    int j,a;

    ProduitsStockDAO stockdao = new ProduitsStockDAO();
    List<ProduitsStock> LPdt = stockdao.findAll();
    a=LPdt.size();
    int t[][]=new int[a][3];

    Iterator it = LPdt.iterator();

    while(it.hasNext()){
    for(j=0;j<t.length;j++){        
        ProduitsStock pdt = (ProduitsStock)it.next();                   

          t[j][0]=pdt.getCodeStock();
          t[j][1]=pdt.getCodePdt();
          t[j][2]=pdt.getQtePdt();
          } }
    return t;
}

and everything works ! 一切正常!

Thank you all :) 谢谢你们 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM