RE: T5: Using with hibernate and Mysql

2008-10-28 Thread BarryDev

Doh typo there, should have been @Column rather than @JoinColumn


BarryDev wrote:
 
 Oh forgot that I'd change the field's name to match the column in that
 class.  If you want to explicitly join a field to a column use the
 @JoinColumn(name = whatever) annotation.
 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-Using-with-hibernate-and-Mysql-tp20166018p20208487.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: T5: Using with hibernate and Mysql

2008-10-27 Thread James Sherwood
Thank you, it seems to have created all the classes with annotations
correctly!

I tried to create a beaneditform off the User class but I get the error:

Exception instantiating instance of com.james.taphib.entities.Users (for
component 'AddUser:user.editor'): Error invoking constructor
com.james.taphib.entities.Users(Occupation, String, String) (at
Users.java:35) (for service 'BeanModelSource'): No service implements the
interface com.james.taphib.entities.Occupation. [at
classpath:org/apache/tapestry5/corelib/components/BeanEditForm.tml, line 7,
column 85]

It is just a base form:

html xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd;
head
titleAdd User/title
/head
body
h1Adding New User/h1
t:beaneditform t:id=user/
/body
/html

And class:

public class AddUser {
@Persist
private Users user;

public Users getUser() {
return user;
}

public void setUser(Users user) {
this.user = user;
}

}

It seems to have trouble with the foreign key to occupation.  I must be
missing a getter or an inject or something.

Any help would be appreciated.

--James


-Original Message-
From: Thiago H. de Paula Figueiredo [mailto:[EMAIL PROTECTED] 
Sent: October-26-08 7:38 PM
To: Tapestry users
Subject: Re: T5: Using with hibernate and Mysql

Em Sun, 26 Oct 2008 16:23:46 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:

 Thank you,

Hi, James!

 You wouldn't have a link to a demo of the JPA generation.
 I use eclipse to generate it and cannot find such a generation type.
 The instructions I used were here:
 http://www.wikihow.com/Generate-Hibernate-Pojo-Classes-from-DB-Tables

Reading it, I'm now sure you have selected the generation of mappings  
using XML.

Take a look at this image:  
http://docs.jboss.org/tools/2.1.0.Beta1/hibernatetools/html/images/plugins/p
lugins_8.png  
 from the Hibernate Tools documentation here:  
http://docs.jboss.org/tools/2.1.0.Beta1/hibernatetools/html/plugins.html#d0e
890.

Check the Use Java syntax and Generate EJB3 annotations options to  
have your mappings done by JPA annotations. ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com

 

__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Using with hibernate and Mysql

2008-10-27 Thread Thiago H. de Paula Figueiredo
Em Mon, 27 Oct 2008 09:20:01 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:



Thank you, it seems to have created all the classes with annotations
correctly!


You're welcome!


I tried to create a beaneditform off the User class but I get the error:

Exception instantiating instance of com.james.taphib.entities.Users (for
component 'AddUser:user.editor'): Error invoking constructor
com.james.taphib.entities.Users(Occupation, String, String) (at
Users.java:35) (for service 'BeanModelSource'):


When instantiating a class, BeanEditForm uses the same approach as the one  
used when you declare some service via ServiceBinder.bind(...). I suggest  
you to instantiate you class yourself before the form is rendered:


@OnEvent(component = yourBeanEditFormIdHere, value=Form.PREPARE)
public void instantiateObject() {
yourField = new Users(..);
}

The prepare event of the Form component is fired before the component is  
rendered and before the form values are set in your object(s) fields.


Another suggestions: rename your Users class to User. :)

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: T5: Using with hibernate and Mysql

2008-10-27 Thread James Sherwood
Thank you again:)

I used:

@OnEvent(component = userEditor, value=Form.PREPARE) public void
instantiateObject() {
user = new User();
}

This produces the form but without a dropdown of occupation.  
The user.occupation is just an occupation object and not a list so how do
you handle foreign keys in beaneditform?

--James

-Original Message-
From: Thiago H. de Paula Figueiredo [mailto:[EMAIL PROTECTED] 
Sent: October-27-08 9:27 AM
To: Tapestry users
Subject: Re: T5: Using with hibernate and Mysql

Em Mon, 27 Oct 2008 09:20:01 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:

 Thank you, it seems to have created all the classes with annotations
 correctly!

You're welcome!

 I tried to create a beaneditform off the User class but I get the error:

 Exception instantiating instance of com.james.taphib.entities.Users (for
 component 'AddUser:user.editor'): Error invoking constructor
 com.james.taphib.entities.Users(Occupation, String, String) (at
 Users.java:35) (for service 'BeanModelSource'):

When instantiating a class, BeanEditForm uses the same approach as the one  
used when you declare some service via ServiceBinder.bind(...). I suggest  
you to instantiate you class yourself before the form is rendered:

@OnEvent(component = yourBeanEditFormIdHere, value=Form.PREPARE)
public void instantiateObject() {
yourField = new Users(..);
}

The prepare event of the Form component is fired before the component is  
rendered and before the form values are set in your object(s) fields.

Another suggestions: rename your Users class to User. :)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com

 

__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Using with hibernate and Mysql

2008-10-27 Thread Thiago H. de Paula Figueiredo
Em Mon, 27 Oct 2008 09:42:25 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:



Thank you again:)


You're welcome again! :)


I used:

@OnEvent(component = userEditor, value=Form.PREPARE) public void
instantiateObject() {
user = new User();
}

This produces the form but without a dropdown of occupation.
The user.occupation is just an occupation object and not a list so how do
you handle foreign keys in beaneditform?


Inside your BeanEditForm, use something like that:

t:parameter name=occupation
select t:type=Select t:model=occupationModel .../
/t:paramater

The t:parameter tag is used by BeanEditForm to override the way some field  
is showed to the user. You can see more details at the end of  
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/BeanEditForm.html.


The Select component is just what you need to edit the occupation field  
and its documentation is here:  
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Select.html


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Using with hibernate and Mysql

2008-10-27 Thread Thiago H. de Paula Figueiredo

Ooops, one detail was forgotten: in order to your occupation field to
appear, you need to add it to the BeanModel used by the BeanEditForm. If
you do not provide one, one is created automatically, and this one does
not include fields that are other entity objects. The easily way to do
that is using the add parameter of BeanEditForm and then providing its
template through t:parameter:

t:beaneditform t:id=user add=occupation
t:parameter name=occupation
...
/t:parameter
/beaneditform

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: T5: Using with hibernate and Mysql

2008-10-27 Thread James Sherwood
Thank you for your quick responses.

I cannot figure out how to produce the SelectionModel from a list of
occupations. I am not sure if I am just being dumb and have been staring at
this too long now or what:)

My method is this:

public SelectModel getOccupationModel(){
return _session.createCriteria(Occupation.class).list();
}

Maybe there is an easier way to get the information from occupation using
hibernate that I am missing as this seems kind of clunky compared to the
advanced nature of the beaneditform.

--James

-Original Message-
From: Thiago H. de Paula Figueiredo [mailto:[EMAIL PROTECTED] 
Sent: October-27-08 9:50 AM
To: Tapestry users
Subject: Re: T5: Using with hibernate and Mysql

Em Mon, 27 Oct 2008 09:42:25 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:

 Thank you again:)

You're welcome again! :)

 I used:

 @OnEvent(component = userEditor, value=Form.PREPARE) public void
 instantiateObject() {
   user = new User();
   }

 This produces the form but without a dropdown of occupation.
 The user.occupation is just an occupation object and not a list so how do
 you handle foreign keys in beaneditform?

Inside your BeanEditForm, use something like that:

t:parameter name=occupation
select t:type=Select t:model=occupationModel .../
/t:paramater

The t:parameter tag is used by BeanEditForm to override the way some field  
is showed to the user. You can see more details at the end of  
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/
corelib/components/BeanEditForm.html.

The Select component is just what you need to edit the occupation field  
and its documentation is here:  
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/
corelib/components/Select.html

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com

 

__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Using with hibernate and Mysql

2008-10-27 Thread Thiago H. de Paula Figueiredo
Em Mon, 27 Oct 2008 10:36:39 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:



I cannot figure out how to produce the SelectionModel from a list of
occupations. I am not sure if I am just being dumb and have been staring  
at this too long now or what:)


Use an SelectModel implementation. You can build it yourself or use  
SelectModelImpl from Tapestry.
You'll need an OptionModel implementation too. You can build it yourself  
or use OptionModelImpl from Tapestry.



My method is this:

public SelectModel getOccupationModel(){
return _session.createCriteria(Occupation.class).list();
}


Your method would look like this (not tested):

public SelectModel getOccupationModel(){
ListOccupation list = 
_session.createCriteria(Occupation.class).list();
ListOptionModel options = new ArrayListOptionModel();
for (Occupation occupation : list) {
options = new OptionModelImpl(occupation.getName(), 
occupation.getId());
}
return new SelectModelImpl(null, options);
}


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: T5: Using with hibernate and Mysql

2008-10-27 Thread James Sherwood
Thank you very much for your help.

Tutorials on this sort of thing are SO hard to find at the moment(and not be
outdated severely or just skim the very surface).

I am quite surprised at the chunkiness of foreign key manipulation when
using the beaneditform when you compare it to the gracefulness of what I
have learned in T5 so far. Maybe this sort of thing will be added to the
tapestry-hibernate libraries in the future though.

I found a nice component for using objects with a select at:
http://wiki.apache.org/tapestry/Tapestry5SelectObject
but could only get it to produce I think the object toString()(I know I
could override it in my class).  I am going to test it more though.

If anyone comes across a nice fairly in-depth tutorial on the whole
tapestry/hibernate scenario I would greatly appreciate it being sent my way
as I am about to start our next big project in T5 as opposed to our current
severely outdated use of T3:)

Thanks again,
--James


-Original Message-
From: Thiago H. de Paula Figueiredo [mailto:[EMAIL PROTECTED] 
Sent: October-27-08 11:13 AM
To: Tapestry users
Subject: Re: T5: Using with hibernate and Mysql

Em Mon, 27 Oct 2008 10:36:39 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:

 I cannot figure out how to produce the SelectionModel from a list of
 occupations. I am not sure if I am just being dumb and have been staring  
 at this too long now or what:)

Use an SelectModel implementation. You can build it yourself or use  
SelectModelImpl from Tapestry.
You'll need an OptionModel implementation too. You can build it yourself  
or use OptionModelImpl from Tapestry.

 My method is this:

 public SelectModel getOccupationModel(){
   return _session.createCriteria(Occupation.class).list();
   }

Your method would look like this (not tested):

public SelectModel getOccupationModel(){
ListOccupation list =
_session.createCriteria(Occupation.class).list();
ListOptionModel options = new ArrayListOptionModel();
for (Occupation occupation : list) {
options = new OptionModelImpl(occupation.getName(),
occupation.getId());
}
return new SelectModelImpl(null, options);
}


-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com

 

__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Using with hibernate and Mysql

2008-10-27 Thread Thiago H. de Paula Figueiredo
Em Mon, 27 Oct 2008 11:55:24 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:



Thank you very much for your help.


You're welcome again. :)

Tutorials on this sort of thing are SO hard to find at the moment(and  
not be outdated severely or just skim the very surface).


Tapestry 5 is new, so tutorials are a little scarce yet.


I am quite surprised at the chunkiness of foreign key manipulation when
using the beaneditform when you compare it to the gracefulness of what I
have learned in T5 so far.


That's why I created the Encoder interface in my Tapestry CRUD library: it  
puts all this enconding (object - primary key, primary key - object,  
object - activation context, activation context, object, etc) in a  
single, reusable place. You can find more about Encoder here:  
http://www.arsmachina.com.br/project/tapestrycrud/concepts.


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Using with hibernate and Mysql

2008-10-26 Thread Szemere Szemere
You're on the right track. Tapestry-hibernate essentially provides the
session per request paradigm in an easy to use way within Tapestry pages.
In the java file for a page you can now add:
@Inject
private Session session;

And any of the methods can use the session to pull data from your database
(via Hibernate).

Szemere


RE: T5: Using with hibernate and Mysql

2008-10-26 Thread BarryDev


James Sherwood wrote:
 
 I still cannot find a good Tapestry-Hibernate tutorial though.  I have a
 rather large database created and would like to generate objects from
 it(this tutorial is the other way around). 
 

Do you mean instead of just declaring an entity class and having hibernate
create the table/schema for you, you want to write classes that are attached
to pre-existing tables in your database?

If so than you need to change a few settings, in hibernate.cfg.xml you need
to change:
 property name=hbm2ddl.autocreate/property   
to
 property name=hbm2ddl.autovalidate/property

This will stop hibernate from trying to create the schema and instead
validate that you got the mappings between objects and tables correct.

Next in your entity classes you now need to define which classes map to
which tables and which fields map to which columns.  This will work if you
follow a certain naming scheme as well I believe (field userName maps to
user_name) but if you want to do it explicitly here's how.

Here's my ChatUser class which maps to table chat_user with a single column
user
@Entity
@Table(name = chat_user)
@AccessType(field)

public class ChatUser implements Serializable {

private static final long serialVersionUID = 8828543828050669616L;

@Id
@Validate(required)
private String userName;

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

@Override
public String toString() {
return userName;
}

}

Hope that helps
-- 
View this message in context: 
http://www.nabble.com/T5%3A-Using-with-hibernate-and-Mysql-tp20166018p20173485.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: T5: Using with hibernate and Mysql

2008-10-26 Thread BarryDev

Oh forgot that I'd change the field's name to match the column in that class. 
If you want to explicitly join a field to a column use the @JoinColumn(name
= whatever) annotation.
-- 
View this message in context: 
http://www.nabble.com/T5%3A-Using-with-hibernate-and-Mysql-tp20166018p20173523.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: T5: Using with hibernate and Mysql

2008-10-26 Thread James Sherwood
Thanks for the information this far,

I have used hibernate-tools to reverse engineer my tables and I built a
small test database to try to work with a foreign key but so far I cannot
get it to work.

My tables are simple:
Users
Userid INTEGER
FirstName VARCHAR
LastName VARCHAR
Ocid INTEGER(The foreign key to occupation)

Occupation
Ocid INTEGER
Ocname VARCHAR

When I generate them using hibernate tools I still have to add the:
@Entity
@Table(name=occupation)
For the table and
@Id
@GeneratedValue
For the id.

The problem is, when I try to run it I get this error:
Could not determine type for: java.util.Set, for columns:
[org.hibernate.mapping.Column(userses)]

This is the foreign key so I assume it is not being generated correctly.

Any help would be appreciated.  Below is my 2 classes;

@Entity
@Table(name=users)
public class Users {

@Id
@GeneratedValue
private Integer userid;
private Occupation occupation;
private String firstName;
private String lastName;

public Users() {
}

public Users(Occupation occupation) {
this.occupation = occupation;
}

public Users(Occupation occupation, String firstName, String
lastName) {
this.occupation = occupation;
this.firstName = firstName;
this.lastName = lastName;
}

public Integer getUserid() {
return this.userid;
}

public void setUserid(Integer userid) {
this.userid = userid;
}

public Occupation getOccupation() {
return this.occupation;
}

public void setOccupation(Occupation occupation) {
this.occupation = occupation;
}

public String getFirstName() {
return this.firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return this.lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

}

@Entity
@Table(name=occupation)
public class Occupation {

@Id
@GeneratedValue
private Integer ocid;
private String ocnamev;
private Set userses = new HashSet(0);

public Occupation() {
}

public Occupation(String ocnamev) {
this.ocnamev = ocnamev;
}

public Occupation(String ocnamev, Set userses) {
this.ocnamev = ocnamev;
this.userses = userses;
}

public Integer getOcid() {
return this.ocid;
}

public void setOcid(Integer ocid) {
this.ocid = ocid;
}

public String getOcnamev() {
return this.ocnamev;
}

public void setOcnamev(String ocnamev) {
this.ocnamev = ocnamev;
}

public Set getUserses() {
return this.userses;
}

public void setUserses(Set userses) {
this.userses = userses;
}

}




-Original Message-
From: BarryDev [mailto:[EMAIL PROTECTED] 
Sent: October-26-08 10:35 AM
To: users@tapestry.apache.org
Subject: RE: T5: Using with hibernate and Mysql


Oh forgot that I'd change the field's name to match the column in that
class. 
If you want to explicitly join a field to a column use the @JoinColumn(name
= whatever) annotation.
-- 
View this message in context:
http://www.nabble.com/T5%3A-Using-with-hibernate-and-Mysql-tp20166018p201735
23.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Using with hibernate and Mysql

2008-10-26 Thread Thiago H. de Paula Figueiredo
Em Sun, 26 Oct 2008 11:31:49 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:



The problem is, when I try to run it I get this error:
Could not determine type for: java.util.Set, for columns:
[org.hibernate.mapping.Column(userses)]


It seems like you chose the Hibernate Core generation type in Hibernate  
Tools. Use the JPA version next time. The error is that the usereses  
property of the Occupation class is an untyped Set. If it was declared as  
a SetUser, it would not complain about this anymore.



@Entity
@Table(name=occupation)
public class Occupation {



public Set getUserses() {
return this.userses;
}

public void setUserses(Set userses) {
this.userses = userses;
}

}


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: T5: Using with hibernate and Mysql

2008-10-26 Thread James Sherwood
Thank you,

You wouldn't have a link to a demo of the JPA generation.

I use eclipse to generate it and cannot find such a generation type.

The instructions I used were here:

http://www.wikihow.com/Generate-Hibernate-Pojo-Classes-from-DB-Tables

--James

-Original Message-
From: Thiago H. de Paula Figueiredo [mailto:[EMAIL PROTECTED] 
Sent: October-26-08 2:45 PM
To: Tapestry users
Subject: Re: T5: Using with hibernate and Mysql

Em Sun, 26 Oct 2008 11:31:49 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:

 The problem is, when I try to run it I get this error:
 Could not determine type for: java.util.Set, for columns:
 [org.hibernate.mapping.Column(userses)]

It seems like you chose the Hibernate Core generation type in Hibernate  
Tools. Use the JPA version next time. The error is that the usereses  
property of the Occupation class is an untyped Set. If it was declared as  
a SetUser, it would not complain about this anymore.

 @Entity
 @Table(name=occupation)
 public class Occupation {

   public Set getUserses() {
   return this.userses;
   }

   public void setUserses(Set userses) {
   this.userses = userses;
   }

 }

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com

 

__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Using with hibernate and Mysql

2008-10-26 Thread Thiago H. de Paula Figueiredo
Em Sun, 26 Oct 2008 16:23:46 -0300, James Sherwood  
[EMAIL PROTECTED] escreveu:



Thank you,


Hi, James!


You wouldn't have a link to a demo of the JPA generation.
I use eclipse to generate it and cannot find such a generation type.
The instructions I used were here:
http://www.wikihow.com/Generate-Hibernate-Pojo-Classes-from-DB-Tables


Reading it, I'm now sure you have selected the generation of mappings  
using XML.


Take a look at this image:  
http://docs.jboss.org/tools/2.1.0.Beta1/hibernatetools/html/images/plugins/plugins_8.png  
from the Hibernate Tools documentation here:  
http://docs.jboss.org/tools/2.1.0.Beta1/hibernatetools/html/plugins.html#d0e890.


Check the Use Java syntax and Generate EJB3 annotations options to  
have your mappings done by JPA annotations. ;)


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: Using with hibernate and Mysql

2008-10-25 Thread James Sherwood
Hello,

 

I was wondering if anyone has a good example of using Tapestry 5 with
Hibernate and Mysql or can tell me what I am doing wrong

 

I use Eclipse/Tomcat/Mysql.

 

I created a new project using Maven:

mvn archetype:create -DarchetypeGroupId=org.apache.tapestry
-DarchetypeArtifactId=quickstart -DgroupId=com.james -DartifactId=taphib
-DpackageName=com.james.taphib -Dversion=1.0.0-SNAPSHOT

 

I added this to my pom.xml

 

dependency

groupIdorg.apache.tapestry/groupId

artifactIdtapestry-hibernate/artifactId

version${tapestry-release-version}/version

  /dependency

  dependency

groupIdmysql/groupId

artifactIdmysql-connector-java/artifactId

version5.1.5/version

  /dependency

 

I created a filed called: hibernate.cfg.xml in src/main/resources

 

?xml version=1.0 encoding=UTF-8?

!DOCTYPE hibernate-configuration PUBLIC

-//Hibernate/Hibernate Configuration DTD 3.0//EN

http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd;

hibernate-configuration

session-factory

property name=hibernate.connection.driver_class

org.gjt.mm.mysql.Driver/property

property name=hibernate.connection.url
jdbc:mysql://localhost/dbname?charset=utf8/property

property name=hibernate.dialect
org.hibernate.dialect.MySQLDialect/property

property name=hibernate.connection.usernameuser/property

property name=hibernate.connection.password/property

 

!-- pool via c3p0 which knows how to reconnect to server and does it

nicely--

property name=connection.provider_class
org.hibernate.connection.C3P0ConnectionProvider/property

property name=hibernate.c3p0.acquire_increment1/property

property name=hibernate.c3p0.idle_test_period100/property !--
seconds --

property name=hibernate.c3p0.max_size10/property

property name=hibernate.c3p0.max_statements0/property

property name=hibernate.c3p0.min_size1/property

property name=hibernate.c3p0.timeout100/property !-- seconds --

 

/session-factory

/hibernate-configuration

 

 

When I try to package using mvn package so I can deploy to eclipse I get
the error: 

INFO]


[ERROR] BUILD ERROR

[INFO]


[INFO] Failed to resolve artifact.

 

Missing:

--

1) org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA

 

  Try downloading the file manually from the project website.

 

  Then, install it using the command:

  mvn install:install-file -DgroupId=org.hibernate
-DartifactId=hibernate-co

mmons-annotations -Dversion=3.1.0.GA -Dpackaging=jar -Dfile=/path/to/file

 

I found a hibernate-commons-annotations.jar but I believe I am doing
something wrong to cause this error.

 

Thanks,

--James



RE: T5: Using with hibernate and Mysql

2008-10-25 Thread James Sherwood
Hello,

I got the project working by adding these to the pom:

dependency
  groupIdorg.hibernate/groupId
  artifactIdhibernate/artifactId
  version3.2.2.ga/version
/dependency
dependency
groupIdc3p0/groupId
artifactIdc3p0/artifactId
version0.9.0/version
/dependency
dependency
  groupIdgeronimo-spec/groupId
  artifactIdgeronimo-spec-jta/artifactId
  version1.0-M1/version
  scopetest/scope
/dependency

And

repository
idAgile Java/id
urlhttp://agilejava.com/maven//url
 /repository

I am not sure if this is correct or not but I can interact with the DB and
have the tutorial at
http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate
Working.

I still cannot find a good Tapestry-Hibernate tutorial though.  I have a
rather large database created and would like to generate objects from
it(this tutorial is the other way around).  I am assuming this may be a
hibernate situation and not tapestry-hibernate but any nudge in the right
direction would be appreciated.

Thanks,
--James

-Original Message-
From: James Sherwood [mailto:[EMAIL PROTECTED] 
Sent: October-25-08 2:11 PM
To: Tapestry users
Subject: T5: Using with hibernate and Mysql

Hello,

 

I was wondering if anyone has a good example of using Tapestry 5 with
Hibernate and Mysql or can tell me what I am doing wrong

 

I use Eclipse/Tomcat/Mysql.

 

I created a new project using Maven:

mvn archetype:create -DarchetypeGroupId=org.apache.tapestry
-DarchetypeArtifactId=quickstart -DgroupId=com.james -DartifactId=taphib
-DpackageName=com.james.taphib -Dversion=1.0.0-SNAPSHOT

 

I added this to my pom.xml

 

dependency

groupIdorg.apache.tapestry/groupId

artifactIdtapestry-hibernate/artifactId

version${tapestry-release-version}/version

  /dependency

  dependency

groupIdmysql/groupId

artifactIdmysql-connector-java/artifactId

version5.1.5/version

  /dependency

 

I created a filed called: hibernate.cfg.xml in src/main/resources

 

?xml version=1.0 encoding=UTF-8?

!DOCTYPE hibernate-configuration PUBLIC

-//Hibernate/Hibernate Configuration DTD 3.0//EN

http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd;

hibernate-configuration

session-factory

property name=hibernate.connection.driver_class

org.gjt.mm.mysql.Driver/property

property name=hibernate.connection.url
jdbc:mysql://localhost/dbname?charset=utf8/property

property name=hibernate.dialect
org.hibernate.dialect.MySQLDialect/property

property name=hibernate.connection.usernameuser/property

property name=hibernate.connection.password/property

 

!-- pool via c3p0 which knows how to reconnect to server and does it

nicely--

property name=connection.provider_class
org.hibernate.connection.C3P0ConnectionProvider/property

property name=hibernate.c3p0.acquire_increment1/property

property name=hibernate.c3p0.idle_test_period100/property !--
seconds --

property name=hibernate.c3p0.max_size10/property

property name=hibernate.c3p0.max_statements0/property

property name=hibernate.c3p0.min_size1/property

property name=hibernate.c3p0.timeout100/property !-- seconds --

 

/session-factory

/hibernate-configuration

 

 

When I try to package using mvn package so I can deploy to eclipse I get
the error: 

INFO]


[ERROR] BUILD ERROR

[INFO]


[INFO] Failed to resolve artifact.

 

Missing:

--

1) org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA

 

  Try downloading the file manually from the project website.

 

  Then, install it using the command:

  mvn install:install-file -DgroupId=org.hibernate
-DartifactId=hibernate-co

mmons-annotations -Dversion=3.1.0.GA -Dpackaging=jar -Dfile=/path/to/file

 

I found a hibernate-commons-annotations.jar but I believe I am doing
something wrong to cause this error.

 

Thanks,

--James




__ Information from ESET Smart Security, version of virus signature
database 3536 (20081019) __

The message was checked by ESET Smart Security.

http://www.eset.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]