NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
marco@netb
Joined: 22 Oct 2011 Posts: 5
|
Posted: Sat Oct 22, 2011 5:35 pm Post subject: GlassFish 3.1 MySQL EclipseLink Auto Schema generation JPA |
|
|
Hi guys!
I have a big problem.
I try to develop a EAR project.
Not difficult, a simple thing to start.
I want to auto generate a database schema from my entity classes. I use GlassFish 3.1 as apllication server and MySQL 5.5 as RDBMS. I create connection pool and JDBC resource in glassfish and ping succeeds. I write a single entity to begin, but when I deploy in GlassFish nothing is created.
This is the only class I write:
| Code: |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author Marco
*/
@Entity
@Table(name="FOLLOWER")
public class FollowerBean implements Serializable {
private String name;
private String surname;
private String email;
private String password;
public FollowerBean() {}
public FollowerBean(String name, String surname, String email, String password) {
this.name = name;
this.surname = surname;
this.email = email;
this.password = password;
}
@Id
@Column(name="EMAIL")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(name="NAME")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name="PASSWORD")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name="SURNAME")
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
}
|
This is my persistence.xml:
| Code: |
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="EnterpriseApplication1-ejbPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/dropcourses</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
|
No errors in deploy, under the app tab in glassfish there is my ear application, but if I open it to see modules and components only the war.
What are the main steps to auto generate a database schema??
I have to add some extra libraries to my project?
It seems that it does nothing when I deploy, that it doesn't try to create table! I don't know what to do.
Please help me!
(Sorry for my english) |
|
| Back to top |
|
 |
tdeit62
Joined: 06 Oct 2011 Posts: 36
|
Posted: Sun Oct 23, 2011 11:28 am Post subject: Re: GlassFish 3.1 MySQL EclipseLink Auto Schema generation JPA |
|
|
Why are you looking in the war for the schema?
Look in your database.
However .. Did you create/define the jbdc resource referred to in the
persistence.xml?
Tony Dietrich
-----Original Message-----
From: marco@netb [mailto:address-removed]
Sent: 22 October 2011 18:36
To: address-removed
Subject: [nbj2ee] GlassFish 3.1 MySQL EclipseLink Auto Schema generation JPA
Hi guys!
I have a big problem.
I try to develop a EAR project.
Not difficult, a simple thing to start.
I want to auto generate a database schema from my entity classes. I use
GlassFish 3.1 as apllication server and MySQL 5.5 as RDBMS. I create
connection pool and JDBC resource in glassfish and ping succeeds. I write a
single entity to begin, but when I deploy in GlassFish nothing is created.
This is the only class I write:
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author Marco
*/
@Entity
@Table(name="FOLLOWER")
public class FollowerBean implements Serializable {
private String name;
private String surname;
private String email;
private String password;
public FollowerBean() {}
public FollowerBean(String name, String surname, String email, String
password) {
this.name = name;
this.surname = surname;
this.email = email;
this.password = password;
}
@Id
@Column(name="EMAIL")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(name="NAME")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name="PASSWORD")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name="SURNAME")
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
}
This is my persistence.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="EnterpriseApplication1-ejbPU"
transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/dropcourses</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
No errors in deploy, under the app tab in glassfish there is my ear
application, but if I open it to see modules and components only the war.
What are the main steps to auto generate a database schema??
I have to add some extra libraries to my project?
It seems that it does nothing when I deploy, that it doesn't try to create
table! I don't know what to do.
Please help me!
(Sorry for my english) |
|
| Back to top |
|
 |
marco@netb
Joined: 22 Oct 2011 Posts: 5
|
Posted: Sun Oct 23, 2011 7:42 pm Post subject: |
|
|
I try to explain better.
I list all the steps I do.
I wanto to auto create a table called FOLLOWER using jpa.
So, this is what I do:
1. New project -> Java EE Enterprise Application (I select GlassFish 3.1 as Application Server, Java EE 6 as Java EE version and I select to create both EJB module and Web Application Module).
2. I create a new database MySQL called drop_courses.
3. Always from netbeans in tab project: New File -> GlassFish: JDBC Resources. This is my settings:
JNDI name: jdbc/dropcourses
Object Type: user
Enabled: true
Description: (blank)
I go next to Choose Database Connection, here I set:
JDBC Connectio Pool Name: dropPOOL
I select the option "extract from exixsting connection" and I choose "jdbc:mysql://localhost:3306/drop_courses"
I go next to Add Connection Pool Properties and I set:
Datasource Classname: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
Resource type: javax.sql.DataSource
Description: (blank)
URL: jdbc:mysql://localhost:3306/drop_courses
User: root
Password: *****
After I click finish
4. In the enterprise application under the folder Server Resources I find the file glassfish-resources.xml which contains the settings before. I click on the ear project and deploy it. In this way the connection pool and jdbc resource are created on the application server. Ping succeeds.
5. Now right click on EnterpriseApplication-ejb -> new entity class, I select:
Class Name: Follower Bean
Project: EnterpriseApplication1-ejb
Location: Source Packages
Package: model
and I select "create Persistence Unit"
Click next and go to Provider and Database, here I select:
Persistence Unit Name: EnterpriseApplication1-ejbPU
Persistence Provider: ElipseLink(JPA 2.0)(Default)
Data Source: jdbc/dropcourses
I select "Use Java Transaction APIs"
I choose for Table Generation Strategy "create"
6. Now I write my FollowerBean class. This is my code:
| Code: |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author Marco
*/
@Entity
@Table(name="FOLLOWER")
public class FollowerBean implements Serializable {
private String name;
private String surname;
private String email;
private String password;
public FollowerBean() {}
public FollowerBean(String name, String surname, String email, String password) {
this.name = name;
this.surname = surname;
this.email = email;
this.password = password;
}
@Id
@Column(name="EMAIL")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(name="NAME")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name="PASSWORD")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name="SURNAME")
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
}
|
And this is my persistence.xml:
| Code: |
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="EnterpriseApplication1-ejbPU"
transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/dropcourses</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
|
7.When I deploy the project nothing was created in the database. No exception during deploy. I don't know what to do and where search to find a solution? Do you know if I forget something??
Thanks to all. |
|
| Back to top |
|
 |
troy giunipero Posted via mailing list.
|
Posted: Mon Oct 24, 2011 1:34 am Post subject: Re: GlassFish 3.1 MySQL EclipseLink Auto Schema generation JPA |
|
|
Are you sure there's "no exception during deploy"? What are you seeing in the IDE's Output window under the GlassFish Server tab?
On 23 October 2011 20:43, marco@netb <address-removed ([email]address-removed[/email])> wrote:
| Quote: | I try to explain better.
I list all the steps I do.
I wanto to auto create a table called FOLLOWER using jpa.
So, this is what I do:
1. New project -> Java EE Enterprise Application (I select GlassFish 3.1 as Application Server, Java EE 6 as Java EE version and I select to create both EJB module and Web Application Module).
2. I create a new database MySQL called drop_courses.
3. Always from netbeans in tab project: New File -> GlassFish: JDBC Resources. This is my settings:
JNDI name: jdbc/dropcourses
Object Type: user
Enabled: true
Description: (blank)
I go next to Choose Database Connection, here I set:
JDBC Connectio Pool Name: dropPOOL
I select the option "extract from exixsting connection" and I choose "jdbc:mysql://localhost:3306/drop_courses"
I go next to Add Connection Pool Properties and I set:
Datasource Classname: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
Resource type: javax.sql.DataSource
Description: (blank)
URL: jdbc:mysql://localhost:3306/drop_courses
User: root
Password: *****
After I click finish
4. In the enterprise application under the folder Server Resources I find the file glassfish-resources.xml which contains the settings before. I click on the ear project and deploy it. In this way the connection pool and jdbc resource are created on the application server. Ping succeeds.
5. Now right click on EnterpriseApplication-ejb -> new entity class, I select:
Class Name: Follower Bean
Project: EnterpriseApplication1-ejb
Location: Source Packages
Package: model
and I select "create Persistence Unit"
Click next and go to Provider and Database, here I select:
Persistence Unit Name: EnterpriseApplication1-ejbPU
Persistence Provider: ElipseLink(JPA 2.0)(Default)
Data Source: jdbc/dropcourses
I select "Use Java Transaction APIs"
I choose for Table Generation Strategy "create"
6. Now I write my FollowerBean class. This is my code:
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author Marco
*/
@Entity
@Table(name="FOLLOWER")
public class FollowerBean implements Serializable {
private String name;
private String surname;
private String email;
private String password;
public FollowerBean() {}
public FollowerBean(String name, String surname, String email, String password) {
this.name = name;
this.surname = surname;
this.email = email;
this.password = password;
}
@Id
@Column(name="EMAIL")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(name="NAME")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name="PASSWORD")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name="SURNAME")
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
}
And this is my persistence.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="EnterpriseApplication1-ejbPU"
transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/dropcourses</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
7.When I deploy the project nothing was created in the database. No exception during deploy. I don't know what to do and where search to find a solution? Do you know if I forget something??
Thanks to all.
|
|
|
| Back to top |
|
 |
tdeit62
Joined: 06 Oct 2011 Posts: 36
|
Posted: Mon Oct 24, 2011 7:36 am Post subject: Re: GlassFish 3.1 MySQL EclipseLink Auto Schema generation JPA |
|
|
Marco
The annotations for the attributes need to be on the declarations, not on the methods.
ie
@ID
@Basic(optional=false)
@Column(name="EMAIL")
private String email;
@Column(name="NAME")
@Basic(optional=false)
private String name;
etc......
Note also that you don't have a generation strategy in your entity class for the ID value. Take a look at the javadocs for javax.persistence.GenerationType
Common examples are
@GeneratedValue(strategy = GenerationType.IDENTITY)
or
@GeneratedValue(strategy = GenerationType.AUTO)
So the declaration for the @ID field would become (for example):
@ID
@Basic(optional=false)
@GeneratedStrategy(strategy=GenerationType.IDENTITY)
@Column ........
The persistence context needs this information to help generate the index for the primary key.
Personally I'd be wary of creating an entity with a String ID. It means that in a database containing multiple entities, you are tying any entities related to that one too closely together, since they need to know about the meaning of the ID value. Also, what happens if, at creation time, you don't HAVE the person's email address? Also consider the fact that an efficient key should be immutable once created, to prevent index churn. Email addresses tend to change....
Take a look at http://www.agiledata.org/essays/keys.html for an explanation on how to choose an appropriate key for your table. Consider the arguments against choosing a key with some business meaning in your application.
Suggest you consider using an Integer ID value as a surrogate primary key with an AUTO generation strategy.
Remember also to use suitable constraints such as @NotNull on your attributes.
Tony Dietrich
-----Original Message-----
From: marco@netb [mailto:address-removed]
Sent: 23 October 2011 20:43
To: address-removed
Subject: [nbj2ee] GlassFish 3.1 MySQL EclipseLink Auto Schema generation JPA
I try to explain better.
I list all the steps I do.
I wanto to auto create a table called FOLLOWER using jpa.
So, this is what I do:
1. New project -> Java EE Enterprise Application (I select GlassFish 3.1 as Application Server, Java EE 6 as Java EE version and I select to create both EJB module and Web Application Module).
2. I create a new database MySQL called drop_courses.
3. Always from netbeans in tab project: New File -> GlassFish: JDBC Resources. This is my settings:
JNDI name: jdbc/dropcourses
Object Type: user
Enabled: true
Description: (blank)
I go next to Choose Database Connection, here I set:
JDBC Connectio Pool Name: dropPOOL
I select the option "extract from exixsting connection" and I choose "jdbc:mysql://localhost:3306/drop_courses"
I go next to Add Connection Pool Properties and I set:
Datasource Classname: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
Resource type: javax.sql.DataSource
Description: (blank)
URL: jdbc:mysql://localhost:3306/drop_courses
User: root
Password: *****
After I click finish
4. In the enterprise application under the folder Server Resources I find the file glassfish-resources.xml which contains the settings before. I click on the ear project and deploy it. In this way the connection pool and jdbc resource are created on the application server. Ping succeeds.
5. Now right click on EnterpriseApplication-ejb -> new entity class, I select:
Class Name: Follower Bean
Project: EnterpriseApplication1-ejb
Location: Source Packages
Package: model
and I select "create Persistence Unit"
Click next and go to Provider and Database, here I select:
Persistence Unit Name: EnterpriseApplication1-ejbPU
Persistence Provider: ElipseLink(JPA 2.0)(Default)
Data Source: jdbc/dropcourses
I select "Use Java Transaction APIs"
I choose for Table Generation Strategy "create"
6. Now I write my FollowerBean class. This is my code:
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author Marco
*/
@Entity
@Table(name="FOLLOWER")
public class FollowerBean implements Serializable {
private String name;
private String surname;
private String email;
private String password;
public FollowerBean() {}
public FollowerBean(String name, String surname, String email, String password) {
this.name = name;
this.surname = surname;
this.email = email;
this.password = password;
}
@Id
@Column(name="EMAIL")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(name="NAME")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name="PASSWORD")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name="SURNAME")
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
}
And this is my persistence.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="EnterpriseApplication1-ejbPU"
transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/dropcourses</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
7.When I deploy the project nothing was created in the database. No exception during deploy. I don't know what to do and where search to find a solution? Do you know if I forget something??
Thanks to all. |
|
| Back to top |
|
 |
marco@netb
Joined: 22 Oct 2011 Posts: 5
|
Posted: Mon Oct 24, 2011 5:55 pm Post subject: |
|
|
Hi, thanks for replies.
I try to follow the advices of tdeiit62. I write a more simple entity class, just to try. This is the code:
| Code: |
package model;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author Marco
*/
@Entity
@Table(name="FOLLOWER")
public class FollowerBean implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional=false)
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="ID")
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof FollowerBean)) {
return false;
}
FollowerBean other = (FollowerBean) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "model.FollowerBean[ id=" + id + " ]";
}
}
|
Again, this is my persistence.xml:
| Code: |
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="DropCourses-ejbPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/dropcourses</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
|
I deploy the ear and first I observe it takes long time. This is what I see from my netbeans IDE under GlassFish tab:
| Code: |
pre-init:
init-private:
init-userdir:
init-user:
init-project:
do-init:
post-init:
init-check:
init:
deps-jar:
deps-j2ee-archive:
DropCourses-ejb.init:
DropCourses-ejb.deps-jar:
DropCourses-ejb.compile:
DropCourses-ejb.library-inclusion-in-manifest:
Building jar: C:\Users\Marco\Documents\NetBeansProjects\DropCourses\DropCourses-ejb\dist\DropCourses-ejb.jar
DropCourses-ejb.dist-ear:
DropCourses-war.init:
DropCourses-war.deps-module-jar:
DropCourses-war.deps-ear-jar:
DropCourses-ejb.init:
DropCourses-ejb.deps-jar:
DropCourses-ejb.compile:
DropCourses-ejb.library-inclusion-in-manifest:
DropCourses-ejb.dist-ear:
DropCourses-war.deps-jar:
DropCourses-war.library-inclusion-in-archive:
DropCourses-war.library-inclusion-in-manifest:
DropCourses-war.compile:
DropCourses-war.compile-jsps:
DropCourses-war.do-ear-dist:
Building jar: C:\Users\Marco\Documents\NetBeansProjects\DropCourses\DropCourses-war\dist\DropCourses-war.war
DropCourses-war.dist-ear:
pre-pre-compile:
pre-compile:
Copying 1 file to C:\Users\Marco\Documents\NetBeansProjects\DropCourses\build
Copying 1 file to C:\Users\Marco\Documents\NetBeansProjects\DropCourses\build
do-compile:
post-compile:
compile:
pre-dist:
post-dist:
dist-directory-deploy:
pre-run-deploy:
Undeploying ...
Initializing...
Initial deploying DropCourses to C:\Users\Marco\Documents\NetBeansProjects\DropCourses\dist\gfdeploy\DropCourses
Completed initial distribution of DropCourses
Initializing...
post-run-deploy:
run-deploy:
BUILD SUCCESSFUL (total time: 2 minutes 32 seconds)
|
Some questions:
1) I have to add some extra libraries to my ear project? EclipseLink libraries for example?
2) The table in the database is created during deploy, right?
3) You have some example of auto schema generation that work?? I don't understand where is the error, I do all the steps correctly!
Thanks. |
|
| Back to top |
|
 |
marco@netb
Joined: 22 Oct 2011 Posts: 5
|
Posted: Mon Oct 24, 2011 8:12 pm Post subject: |
|
|
This is what I read from a guide:
| Code: |
Deploying the Application
1. In the Projects window, right-click the SavingsAccount project node and
choose Deploy Project. The IDE does the following
• Builds the EJB module
• Starts the application server if it is not already started
• Configures the data source and connection pool on the application
server
• Deploys the EJB module to the application server
2. In the Runtime window, expand Servers→Sun Java System Application
Server→Applications→EJB Modules and verify that the SavingsAccount
EJB module exists on the server.
|
This guide is not for GlassFish but the reasoning is the same. If I open admin console of GlassFish, under the tab applications there is my ear project. If I open it inside only the war, no ejb modules! I don't understand ... It seems that deploy only war which is inside the ear. |
|
| Back to top |
|
 |
tdeit62
Joined: 06 Oct 2011 Posts: 36
|
Posted: Tue Oct 25, 2011 6:12 am Post subject: Re: GlassFish 3.1 MySQL EclipseLink Auto Schema generation JPA |
|
|
Do you actually HAVE any EJB classes in the ejb project?
An entity class is not an ejb. Try using the session Bean from entity class wizard to create a Session Bean ejb in your EJB project, then see what happens.
Tony Dietrich
-----Original Message-----
From: marco@netb [mailto:address-removed]
Sent: 24 October 2011 21:12
To: address-removed
Subject: [nbj2ee] GlassFish 3.1 MySQL EclipseLink Auto Schema generation JPA
This is what I read from a guide:
Code:
Deploying the Application
1. In the Projects window, right-click the SavingsAccount project node and
choose Deploy Project. The IDE does the following
• Builds the EJB module
• Starts the application server if it is not already started
• Configures the data source and connection pool on the application
server
• Deploys the EJB module to the application server
2. In the Runtime window, expand Servers→Sun Java System Application
Server→Applications→EJB Modules and verify that the SavingsAccount
EJB module exists on the server.
This guide is not for GlassFish but the reasoning is the same. If I open admin console of GlassFish, under the tab applications there is my ear project. If I open it inside only the war, no ejb modules! I don't understand ... It seems that deploy only war which is inside the ear. |
|
| Back to top |
|
 |
galmo
Joined: 29 Oct 2011 Posts: 1
|
Posted: Sat Oct 29, 2011 7:57 am Post subject: ddl-generation issue with NB and GF |
|
|
Hi
Tony's right you have to create an EJB and you'll have to define inside an entity manager specifying GF the persistence context & datasource to manage. In my example below, Test-ejbPU, in yours to be replaced by DropCourses-ejbPU
package stateless;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Stateless
@LocalBean
public class TestBean {
@PersistenceContext(unitName = "Test-ejbPU")
private EntityManager em;
}
Gerald |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|