-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Problems setting up one-to-mny relationship
PostPosted: Fri Jan 30, 2004 5:54 am 
Regular
Regular

Joined: Mon Jan 19, 2004 10:39 pm
Posts: 84
Location: Nottingham, England
Hi,
I am having problems setting up a one to many relationship between 2 classes. My first class test.User has the PK on a table column of user_id and the second class test.ArtistChoice has the foreign key reference. When I try to load the page nothing is displayed. What am I doing wrong? Am i right in commenting out the UserID property line in test.ArtistChoice and replacing it with the many-to-one line?

1. Primary key class

<class name="test.User" table="usertbl">
<id name="ID" column="user_id" type="integer" unsaved-value="0">
<generator class="sequence">
<param name="sequence">seq_id_mytable</param>
</generator>
</id>

<property name="FirstName" column="first_name" type="string" not-null="true" />
<property name="LastName" column="last_name" type="string" not-null="true" />
<property name="Address1" column="address1" type="string" />
<property name="Address2" column="address2" type="string" />
<property name="Address3" column="address3" type="string" />
<property name="PostCode" column="postcode" type="string" />
<property name="Country" column="country" type="string" />
<property name="Email" column="email" type="string" not-null="true" />
<property name="HomeTel" column="home_telephone" type="string" />
<property name="HomeMob" column="mobile_telephone" type="string" />
<property name="DateJoined" column="date_joined" type="timestamp" />
<property name="UserName" column="username" type="string" not-null="true" />
<property name="UserPassword" column="userpassword" type="string" not-null="true" />

<set name="artistchoice" lazy="true" cascade="delete" inverse="true">
<key column="user_id"/>
<one-to-many class="test.ArtistChoice" />
</set>

</class>

2. foreign key class

<class name="test.ArtistChoice" table="choicetbl">
<id name="ID" column="id_key" type="integer" unsaved-value="0">
<generator class="sequence">
<param name="sequence">seq_artistchoice_mytable</param>
</generator>
</id>

<!--<property name="UserID" column="user_id" type="integer" not-null="true" />-->
<property name="ArtistID" column="artist_id" type="integer" not-null="true" />
<many-to-one name="UserID" column="user_id" class="test.User" not-null="true" />

</class>

many thanks in advance

Andrew


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2004 8:31 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
I can't spot anything obviously wrong...
Quote:
Am i right in commenting out the UserID property line in test.ArtistChoice and replacing it with the many-to-one line?

Yes - if you want to model a bidirectional one-to-many relationship.

The fact that nothing is being displayed is suspicous. I suspect an exception is being thrown but that you are unaware of it.
Enable logging (net.sf.hibernate=debug) and post the trace,.

Justin


Top
 Profile  
 
 Post subject: Trace
PostPosted: Fri Jan 30, 2004 12:12 pm 
Regular
Regular

Joined: Mon Jan 19, 2004 10:39 pm
Posts: 84
Location: Nottingham, England
Justin,
as requested here is the trace:

Jan 30, 2004 3:54:28 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.1
Jan 30, 2004 3:54:28 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Jan 30, 2004 3:54:28 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jan 30, 2004 3:54:28 PM net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jan 30, 2004 3:54:28 PM net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Jan 30, 2004 3:54:28 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/User.hbm.xml
Jan 30, 2004 3:54:28 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.User -> usertbl
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Artist.hbm.xml
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Artist -> artisttbl
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/ArtistChoice.hbm.xml
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.ArtistChoice -> choicetbl
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Artist_TourDates.hbm.xml
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Artist_TourDates -> artist_tourdatestbl
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Stock.hbm.xml
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Stock -> stocktbl
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Downloads.hbm.xml
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Downloads -> downloadstbl
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Demos.hbm.xml
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Demos -> new_artist_demostbl
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Accounts.hbm.xml
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Accounts -> user_accountstbl
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/ShoppingCart.hbm.xml
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.ShoppingCart -> shopping_carttbl
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass
INFO: Mapping collection: test.User.choice -> choicetbl
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jan 30, 2004 3:54:29 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.PostgreSQLDialect
Jan 30, 2004 3:54:29 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
Jan 30, 2004 3:54:29 PM net.sf.hibernate.connection.C3P0ConnectionProvider configure
INFO: C3P0 using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5432/beyarecords
Jan 30, 2004 3:54:29 PM net.sf.hibernate.connection.C3P0ConnectionProvider configure
INFO: Connection properties: {user=x, password=x}
Jan 30, 2004 3:54:29 PM net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
Jan 30, 2004 3:54:30 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
Jan 30, 2004 3:54:30 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC 2 max batch size: 15
Jan 30, 2004 3:54:30 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: echoing all SQL to stdout
Jan 30, 2004 3:54:30 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Jan 30, 2004 3:54:30 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.ehcache.hibernate.Provider
Jan 30, 2004 3:54:30 PM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
Jan 30, 2004 3:54:30 PM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Jan 30, 2004 3:54:31 PM org.apache.jk.server.JkCoyoteHandler action
INFO: Response already commited


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2004 1:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
ArtistChoice.setUserID(myUser); is not done or you don't flush or you don't commit, or your getter/setter are broken[/code]

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Resolution?
PostPosted: Fri Jan 30, 2004 7:10 pm 
Regular
Regular

Joined: Mon Jan 19, 2004 10:39 pm
Posts: 84
Location: Nottingham, England
Ok,
the problem was that I did not name the name atribute of the many-to-one property to ID which is the same value as the id attribute. So I have:

<class name="test.ArtistChoice" table="choicetbl">
<id name="ID" column="id_key" type="integer" unsaved-value="0">
<generator class="sequence">
<param name="sequence">seq_artistchoice_mytable</param>
</generator>
</id>

<!--<property name="UserID" column="user_id" type="integer" not-null="true" />-->
<property name="ArtistID" column="artist_id" type="integer" not-null="true" />
<many-to-one name="ID" class="test.User" column="user_id" />

</class>

So, am I right in thinking that:

<many-to-one name="ID" class="test.User" column="user_id" />

creates a many-to-one relationship based on the ID of test.ArtistChoice instead of test.User? How does that line of code actually work as it seems to reference itself?


User.

<class name="test.User" table="usertbl">
<id name="ID" column="user_id" type="integer" unsaved-value="0">
<generator class="sequence">
<param name="sequence">seq_id_mytable</param>
</generator>
</id>

<property name="FirstName" column="first_name" type="string" not-null="true" />
<property name="LastName" column="last_name" type="string" not-null="true" />
<property name="Address1" column="address1" type="string" />
<property name="Address2" column="address2" type="string" />
<property name="Address3" column="address3" type="string" />
<property name="PostCode" column="postcode" type="string" />
<property name="Country" column="country" type="string" />
<property name="Email" column="email" type="string" not-null="true" />
<property name="HomeTel" column="home_telephone" type="string" />
<property name="HomeMob" column="mobile_telephone" type="string" />
<property name="DateJoined" column="date_joined" type="timestamp" />
<property name="UserName" column="username" type="string" not-null="true" />
<property name="UserPassword" column="userpassword" type="string" not-null="true" />

<!--
<set name="ID" lazy="true" cascade="delete" inverse="true">
<key column="user_id"/>
<one-to-many class="test.ArtistChoice" />
</set>
-->
</class>

many thanks

Andrew


Top
 Profile  
 
 Post subject: Re: Resolution?
PostPosted: Sat Jan 31, 2004 7:20 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
dukeswharf wrote:
the problem was that I did not name the name atribute of the many-to-one property to ID which is the same value as the id attribute. So I have:

No its is wrong, name attribute means the java property name, it must not be the same.
dukeswharf wrote:
So, am I right in thinking that:

<many-to-one name="ID" class="test.User" column="user_id" />

creates a many-to-one relationship based on the ID of test.ArtistChoice instead of test.User? How does that line of code actually work as it seems to reference itself?

This is wrong. This line means you have a setID(User) and User getID() in ArtistChoice (no relationship with object id).
Actually, Hibernate will save the associate User id into the user_id column of ArtistChoice table.

I strongly advise you to read the parent child relationship chapter again.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Emmanuel
PostPosted: Sat Jan 31, 2004 9:38 am 
Regular
Regular

Joined: Mon Jan 19, 2004 10:39 pm
Posts: 84
Location: Nottingham, England
i have read the documentation but find it very vague! Just to clarify what you said earlier:

<many-to-one name="name of mychoice" class="Parent Class" column="name of column in child table"/>

where:

1. Name- Any name of my choosing. Only for reference purposes in sql statements?

2. Class - name of parent object for which an association is made to the getID of that class?

3. Column - name of the column in the child table which is used to hold the parent class ID?

thanks in advance


Andrew


Top
 Profile  
 
 Post subject: slight..
PostPosted: Sat Jan 31, 2004 10:08 am 
Regular
Regular

Joined: Mon Jan 19, 2004 10:39 pm
Posts: 84
Location: Nottingham, England
amendement to my earlier post. In terms of the name atrribute of the many-to-one property:

1 Name - the name of the getter/setter name in the child java class?

So:

public class ArtistChoice{

private int childID;
private int UserID;
private int ArtistID;


public ArtistChoice(){
}

public int getchildID() {
return ID;
}
public void setchildID(int newID) {
this.ID = newID;
}

public int getUserID() {
return UserID;
}
public void setUserID(int newUserID) {
this.UserID = newUserID;
}

public int getArtistID() {
return ArtistID;
}
public void setArtistID(int newArtistID) {
this.ArtistID = newArtistID;
}

}

In this instance Name = childID?

or is name refernce to the parent ID the parent java class, i.e

name = parentID?

public class User{

private int parentID;
private String FirstName;
private String LastName;
private String Address1;
private String Address2;
private String Address3;
private String PostCode;
private String Country;
private String Email;
private String HomeTel;
private String HomeMob;
private Date DateJoined;
private String UserName;
private String UserPassword;

public User(){
}

public int getparentID() {
return ID;
}
public void setparentID(int newUserID) {
this.ID = newUserID;
}

public String getFirstName() {
return (FirstName);
}
public void setFirstName(String newfirstName) {
this.FirstName = newfirstName;
}

public String getLastName() {
return (LastName);
}
public void setLastName(String newlastName) {
this.LastName = newlastName;
}

public String getAddress1() {
return Address1;
}
public void setAddress1(String newAddress1) {
this.Address1 = newAddress1;
}

public String getAddress2() {
return Address2;
}
public void setAddress2(String newAddress2) {
this.Address2 = newAddress2;
}

public String getAddress3() {
return Address3;
}
public void setAddress3(String newAddress3) {
this.Address3 = newAddress3;
}

public String getPostCode() {
return PostCode;
}
public void setPostCode(String newPostCode) {
this.PostCode = newPostCode;
}

public String getCountry() {
return Country;
}
public void setCountry(String newCountry) {
this.Country = newCountry;
}

public String getEmail() {
return Email;
}
public void setEmail(String newEmail) {
this.Email = newEmail;
}

public String getHomeTel() {
return HomeTel;
}
public void setHomeTel(String newHomeTel) {
this.HomeTel = newHomeTel;
}

public String getHomeMob() {
return HomeMob;
}
public void setHomeMob(String newHomeMob) {
this.HomeMob = newHomeMob;
}

public Date getDateJoined() {
return DateJoined;
}
public void setDateJoined(Date newDateJoined) {
this.DateJoined = newDateJoined;
}

public String getUserName() {
return UserName;
}
public void setUserName(String newUserName) {
this.UserName = newUserName;
}

public String getUserPassword() {
return UserPassword;
}
public void setUserPassword(String newUserPassword) {
this.UserPassword = newUserPassword;
}

}

many thanks

Andrew


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 31, 2004 10:11 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The "name" is the name of the property of the persistent class. I think you have to read some of the Hibernate basics again. :) If the Hibernate documentation is not enough, try one of the many articles about Hibernate.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Ah.... ok
PostPosted: Sat Jan 31, 2004 10:37 am 
Regular
Regular

Joined: Mon Jan 19, 2004 10:39 pm
Posts: 84
Location: Nottingham, England
all has become clear now. name refers to a child get/set pair that holds the value of the parentID!!!!

I hope you guys don't mind if I rewrite parts of the manual as and when I come across them!!!?? ;-)


Andrew


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 31, 2004 10:44 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Actually, the Hibernate reference documentation is not a "tutorial", so if you really want to start from scratch without any Hibernate knowhow, read one of the articles, the Quickstart or wait for "Hibernate in Action" ;). The reference is just that, but even not written in prose, it already has > 100 pages. Imagine a detailed discussion of that material...

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: When
PostPosted: Sat Jan 31, 2004 12:15 pm 
Regular
Regular

Joined: Mon Jan 19, 2004 10:39 pm
Posts: 84
Location: Nottingham, England
is Hibernate in Action sue to be released?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 31, 2004 12:18 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Quoting Christian: The book will be in print second quarter 2004

This seem to be an FAQ :)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Null error
PostPosted: Sat Jan 31, 2004 12:51 pm 
Regular
Regular

Joined: Mon Jan 19, 2004 10:39 pm
Posts: 84
Location: Nottingham, England
I have amended my user and artistchoice classes plus the hbm.xml files as so:

A. artistChoice:

1. Class addition

private Vector ArtistChoice = new Vector();
......

public int getUser() {
return User;
}
public void setUser(int newUser) {
this.User = newUser;
}

2. hbm.xml addition

<many-to-one name="User" class="test.User" column="user_id" cascade="all"/>

B. User:

1. Class addition

private int ArtistChoice;
........

public Vector getArtistChoice() {
return ArtistChoice;
}
public void setArtistChoice(Vector newArtistChoice) {
this.ArtistChoice = newArtistChoice;
}

2. hbm.xml addition

<set name="ArtistChoice" lazy="true" cascade="delete" inverse="true">
<key column="artistchoice"/>
<one-to-many class="test.ArtistChoice" />
</set>

Now I am getting the following error log. What am I doing wrong?


INFO: hibernate.properties not found
Jan 31, 2004 4:38:49 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jan 31, 2004 4:38:50 PM net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jan 31, 2004 4:38:50 PM net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Jan 31, 2004 4:38:50 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/User.hbm.xml
Jan 31, 2004 4:38:50 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.User -> usertbl
Jan 31, 2004 4:38:50 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Artist.hbm.xml
Jan 31, 2004 4:38:50 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Artist -> artisttbl
Jan 31, 2004 4:38:50 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/ArtistChoice.hbm.xml
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.ArtistChoice -> choicetbl
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Artist_TourDates.hbm.xml
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Artist_TourDates -> artist_tourdatestbl
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Stock.hbm.xml
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Stock -> stocktbl
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Downloads.hbm.xml
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Downloads -> downloadstbl
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Demos.hbm.xml
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Demos -> new_artist_demostbl
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/Accounts.hbm.xml
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.Accounts -> user_accountstbl
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: test/ShoppingCart.hbm.xml
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: test.ShoppingCart -> shopping_carttbl
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass
INFO: Mapping collection: test.User.ArtistChoice -> choicetbl
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jan 31, 2004 4:38:51 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.PostgreSQLDialect
Jan 31, 2004 4:38:51 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
Jan 31, 2004 4:38:51 PM net.sf.hibernate.connection.C3P0ConnectionProvider configure
INFO: C3P0 using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5432/beyarecords
Jan 31, 2004 4:38:51 PM net.sf.hibernate.connection.C3P0ConnectionProvider configure
INFO: Connection properties: {user=postgres, password=postgres}
Jan 31, 2004 4:38:51 PM net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
Jan 31, 2004 4:38:52 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
Jan 31, 2004 4:38:52 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC 2 max batch size: 15
Jan 31, 2004 4:38:52 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: echoing all SQL to stdout
Jan 31, 2004 4:38:52 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Jan 31, 2004 4:38:52 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.ehcache.hibernate.Provider
Jan 31, 2004 4:38:52 PM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
Jan 31, 2004 4:38:52 PM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Jan 31, 2004 4:38:54 PM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: no JNDI name configured
Hibernate: select nextval ('seq_id_mytable')
Exception in Hibernate:null

Andrew


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 31, 2004 2:33 pm 
Regular
Regular

Joined: Mon Jan 19, 2004 10:39 pm
Posts: 84
Location: Nottingham, England
further to my last post, I have managed to get logj4 working and hense better debugging. The last line is where the fun begins, why is it bombing out?

18:14:14,489 DEBUG Cascades:497 - processing cascades for: test.User
18:14:14,491 DEBUG Cascades:506 - done processing cascades for: test.User
18:14:14,507 DEBUG Cascades:497 - processing cascades for: test.User
18:14:14,509 DEBUG Cascades:506 - done processing cascades for: test.User
18:14:14,510 DEBUG JDBCTransaction:59 - commit
18:14:14,512 DEBUG SessionImpl:2193 - flushing session
18:14:14,518 DEBUG Cascades:497 - processing cascades for: test.User
18:14:14,520 DEBUG Cascades:506 - done processing cascades for: test.User
18:14:14,521 DEBUG SessionImpl:2321 - Flushing entities and processing referenced collections
18:14:14,564 DEBUG WrapVisitor:76 - Wrapped collection in role: test.User.ArtistChoice
Exception in Hibernate:exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of test.User.setArtistChoice

My code is:

User2 usr2 = new User2();
Date newDate = new Date();
User usr = new User();

usr.setID(1);
usr.setFirstName("C");
usr.setLastName("M");
usr.setAddress1("1 trump towers");
usr.setAddress2("france");
usr.setAddress3("wewew");
usr.setPostCode("wewewe");
usr.setCountry("England");
usr.setEmail("test@hotmail.com");
usr.setHomeTel("00000");
usr.setHomeMob("00000");
usr.setDateJoined(newDate);
usr.setUserName("kings");
usr.setUserPassword("queens");

usr2.add(usr);

The User class is:

public class User{

.....................
private Vector ArtistChoice = new Vector();

....................
public Vector getArtistChoice() {
return ArtistChoice;
}
public void setArtistChoice(Vector newArtistChoice) {
this.ArtistChoice = newArtistChoice;
}

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


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

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.