[Hibernate] proxy, abstract class, ClassCastException.

2003-09-10 Thread jiesheng zhang
My problem is that I know one object is type A, but
when I try to cast to A, I got a ClassCastException.

I have four classes in my cases: ContentDB,
ServerFileSysNode, InnerNode, and SharedFileSysNode. 
ServerFileSysNode(abstract)
InnerNode (concrete subclass of ServerFileSysNode,
may have an asscoaited 
SharedFileSysNode).
...(other subclass of ServerFileSysNode is omitted
here ).
ShareFileSysNode 
always associated with a ServerFileSysNode
ContentDB( a list of ServerFileSysNode, a list of
SharedFileSysNode).
Their mapping are shown at the bottom.


In my application initialization, I loaded all the
ServerFileSysNode and ShareFileSysNode in the 
ContentDB. However I found that if an InnerNode does
not have an associated SharedFileSysNode, the 
InnerNode will have a type of "InnerNode", that is
correct. Otherwise, it will have a type of 
"ServerFileSysNode$$EnhancedByCGLIB$$00",  and the
"ServerFileSysNode$$EnhancedByCGLIB$$00" can 
not cast back to "InnerNode". I just wonder how the
hibernate decides that the object should be 
"ServerFileSysNode$$EnhancedByCGLIB$$00". Since
ServerFileSysNode is an abstract clas. In my 
database, there is no instance which is object of
"ServerFileSysNode"

Also I did not use the Session.load(Class, id) method
to load the object explicitly. All the objects
are loaded by association with the ContentDB.

Help is appreciated.





  

  
seq_resourceID
  


  


  
  
  


  
  
 
 
 
 

 


seq_resourceID




  




  


   
 

   


hardNode





   
 



__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] proxy, abstract class, ClassCastException.

2003-09-10 Thread Gavin King
If you configure a polymorphic association to use proxies,
this is what happens.
If you need to do a typecast, either:

(1) use outer-join="true" on the association OR
(2) call session.load(Subtype.class, proxy.getId() )
   to narrow the proxy type.
we can't possibly know a subtype w/o hitting the db.

jiesheng zhang wrote:

My problem is that I know one object is type A, but
when I try to cast to A, I got a ClassCastException.
I have four classes in my cases: ContentDB,
ServerFileSysNode, InnerNode, and SharedFileSysNode. 
ServerFileSysNode(abstract)
	InnerNode (concrete subclass of ServerFileSysNode,
may have an asscoaited 
			SharedFileSysNode).
	...(other subclass of ServerFileSysNode is omitted
here ).
ShareFileSysNode 
	always associated with a ServerFileSysNode
ContentDB( a list of ServerFileSysNode, a list of
SharedFileSysNode).
Their mapping are shown at the bottom.

In my application initialization, I loaded all the
ServerFileSysNode and ShareFileSysNode in the 
ContentDB. However I found that if an InnerNode does
not have an associated SharedFileSysNode, the 
InnerNode will have a type of "InnerNode", that is
correct. Otherwise, it will have a type of 
"ServerFileSysNode$$EnhancedByCGLIB$$00",  and the
"ServerFileSysNode$$EnhancedByCGLIB$$00" can 
not cast back to "InnerNode". I just wonder how the
hibernate decides that the object should be 
"ServerFileSysNode$$EnhancedByCGLIB$$00". Since
ServerFileSysNode is an abstract clas. In my 
database, there is no instance which is object of
"ServerFileSysNode"

Also I did not use the Session.load(Class, id) method
to load the object explicitly. All the objects
are loaded by association with the ContentDB.
Help is appreciated.




 
   
unsaved-value="0">
 
   seq_resourceID
 
   

 
inverse="true">
   
   
 
 
 
lazy="true" inverse="true" cascade="save-update">
   
   
 
 






discriminator-value='s' proxy="ServerFileSysNode">
 	
unsaved-value="0">
 		
   		
name="sequence">seq_resourceID
	 	
   	
   	
   
   
class="ContentDB" cascade="none"/>	

   	
class="SharedFileSysNode"/>
   	
   	
discriminator-value="i" proxy="InnerNode">
   		
   	
   
  

	
  
proxy="SharedFileSysNode" >
  		
unsaved-value="0">
 		
 			hardNode
 		
   	
   	
	
class="ServerFileSysNode" cascade="none"
constrained="true"/>
   	
class="ContentDB" cascade="none"/>
  



__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel
 



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] self-referential table

2003-09-10 Thread sw-list
On Tuesday, September 9, 2003, at 07:07 PM, Gavin King wrote:

Theres nothing particularly special about this. Just map it as you 
would any other association.

The only problem is your -1, which breaks referential integrity of the 
whole table! just switch to using an SQL null.
Ok, I guess this is where I'm having a problem. How do I map this like 
any other association? BTW - I'm using Xdoclet for my mapping 
generation.

Here's what I defined for my collection:
  



   
  
  
  

Thanks for the assistance.

-warner

[EMAIL PROTECTED] wrote:

Alright, so I've searched all over the web (this list doesn't appear 
to be archived either), so here I am ;-).

I am finally getting into using Hibernate on a few projects and have 
run across something that I'm sure how it would be handled. I have 
one table that uses itself as a collection.

Basically the table looks like this:
create table Category (
   id VARCHAR(255) not null,
   parentid VARCHAR(255),
   name VARCHAR(255),
   description VARCHAR(255),
   primary key (id)
)
Where parentid is the parent of this category. If it's -1 then it's a 
root category (if there's a better way to do this please let me know.

What I'm unclear on is how to represent this in a mapping (and 
class-wise). I want to have a method getSubCategories which will 
return a set of Categories.

Thanks in advance,
Warner


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] Question on Session.connection

2003-09-10 Thread Chandrasekhar Ambadipudi

I have a  transaction like this

Transaction tx = sess.beginTransaction();
sess.save(obj)
sess.connection() // and  one prepared
statment execution here
sess.update(obj1)
tx.commit();

How ever the sess.save() in line 2 and sess.update() in line 4 are
getting executed at the time of commit when I call tx.commit().  but the
prepared statement execution is done immediately, my prepared statement
execution depends on sess.save() in line 2, but since line 2 and line 4 are
executed after my line 3 related code Iam getting a foreign key exception in
my code, because by the time I execute linke number 3 here code assumes the
line 2 has been executed and the entry has been made on the table.

Is there a way I can tell hibernate to execute line  2,3,4 in
sequence and not to wait till tx.commit() or  other way can I can hint
hibernate not to execute line 3 until commit time ?

Thanks
Chandra


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] CVS Problems

2003-09-10 Thread Michael Gloegl
Hi everybody,

when trying to connect to the CVS I constantly get "EOF from Server" and 
"Connection Reset by Peer" errors. Is anyone else having such problems 
in the moment?

Michael



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] Question on Session.connection

2003-09-10 Thread Gavin King
Just call sess.flush() ... you can call it at any time :)

Chandrasekhar Ambadipudi wrote:

	I have a  transaction like this

Transaction tx = sess.beginTransaction();
sess.save(obj)
sess.connection() // and  one prepared
statment execution here
sess.update(obj1)
tx.commit();
How ever the sess.save() in line 2 and sess.update() in line 4 are
getting executed at the time of commit when I call tx.commit().  but the
prepared statement execution is done immediately, my prepared statement
execution depends on sess.save() in line 2, but since line 2 and line 4 are
executed after my line 3 related code Iam getting a foreign key exception in
my code, because by the time I execute linke number 3 here code assumes the
line 2 has been executed and the entry has been made on the table.
Is there a way I can tell hibernate to execute line  2,3,4 in
sequence and not to wait till tx.commit() or  other way can I can hint
hibernate not to execute line 3 until commit time ?
Thanks
Chandra
---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel
 



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] What is the difference between version 2.0.3 and 2.1??

2003-09-10 Thread Vivian Fonger
Title: Message



Hi 
everyone,
 
Can anyone give me 
the difference between version 2.0.3 and version 2.1.?? Will I have any problem 
to upgrade from version 2.0.3 to version 2.1 when the version 2.1 becomes 
stable??
 
Vivian Fonger
Software Engineer
Socketware
[EMAIL PROTECTED]
 


[Hibernate] Reducing startup time (with a small solution)

2003-09-10 Thread Andrea Aime
Hi Gavin, hi everybody,
it seems I've found a way to reduce even further the startup
time of my application. Basically, I've changed the sax parser
to the RealtimeParser included in Jade (jade.dautelle.com) and
had to comment out the reader.setValidation(true); in the
XMLHelper.CreateSaxReader(string) method. Further checks
on my machine seems to suggest that avoiding validation
takes down the startup time from 6.5 to 3.6 seconds, and
using jade parser lowers it further to 2.6 seconds. Not bad :-),
it would really nice if there was an option to avoid validation,
I usually check xml validity with the IDE anyway (you don't
need to check it again and again when you're in production, and
morevoer a reduced startup time means more productive debugging ;-)

Oh, PC is a Duron 1200, 512 MB RAM, Win2000, j2sdk1.4.2_01.

Best regards
Andrea Aime



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] How to use JCS in Hibernate

2003-09-10 Thread Yin Shi
Hi all,

In our database, there is a table called codsc.  We access the codsc table 
many times in all parts of our application.  The data rarely changes, 
so it is a good candidate for caching.

The primary key of codsc is id, code.  
The columns we need cached are desc, dstat.

Basically we want the JCS to do is:

- We need to be able to request the data by primary key.

- We want the first request to actually retrieve the data.

- After the first request, the cached data should be returned.

- We do not need to write the data back out to the database.

- It would be nice if the cached data would expire after a period of time, 
and refresh the data from the database.

I found out there is JCS in Hibernate, but I never used it before, I am not sure 
if it fits my project or not?  Did anyone try JCS in Hibernate before?  And could
you give me an simple example how to do it? 

Thank you all so much!

 




__
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


RE: [Hibernate] CVS Problems

2003-09-10 Thread Schnitzer, Jeff
> From: Michael Gloegl [mailto:[EMAIL PROTECTED]
> 
> when trying to connect to the CVS I constantly get "EOF from Server"
and
> "Connection Reset by Peer" errors. Is anyone else having such problems
> in the moment?

Yes.  I was getting them yesterday too.

(using anonymous cvs)

Jeff Schnitzer
[EMAIL PROTECTED]


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] MappingException: Repeated column in mapping for collection (no idea what is it)

2003-09-10 Thread Vivian Fonger
Title: Message



Hi 
everyone,
 
I got the following 
error at hibernate version 2.0.3 and I have no idea what does it 
mean?? 
 
net.sf.hibernate.MappingException: Repeated column in 
mapping for collection: com.accucast4.testcase5.Customer.recipients column: 
RC_C_ID at 
net.sf.hibernate.collection.CollectionPersister.checkColumnDuplication(CollectionPersister.java:838) at 
net.sf.hibernate.collection.CollectionPersister.(CollectionPersister.java:214) at 
net.sf.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:216) at 
net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627) at 
com.accucast4.customerdatasource.CustomerDataSourceConfigurationFactory.addSessionManagementHolder(CustomerDataSourceConfigurationFactory.java:62) at 
com.accucast4.customerdatasource.CustomerDataSourceConfigurationFactory.retrieveDataSourceCfgHolder(CustomerDataSourceConfigurationFactory.java:85) at 
com.accucast4.customerdatasource.CustomerDataSourceConfigurationFactory.getSession(CustomerDataSourceConfigurationFactory.java:107) at 
com.accucast3.kernel.test.TestCustomerDataSourceConfiguration.getSession(TestCustomerDataSourceConfiguration.java:32) at 
com.accucast3.kernel.Kernel.getSession(Kernel.java:62) at 
com.accucast3.kernel.Kernel.main(Kernel.java:75)
 
Does anyone have any 
idea??  Here is the customer mapping file:
 
    "-//Hibernate/Hibernate Mapping 
DTD//EN"    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" 
>    
 
    
name="com.accucast4.testcase5.Customer"     
table="CUSTOMER">    
    
name="custId"    
type="long"    
column="CUST_ID"    
>            
    
name="firstName"    
type="java.lang.String"    
column="FIRST_NAME"    
length="20"    />
        
    
name="recipients"    
lazy="true"    
inverse="true" cascade="all"       
>    
    
    
        
    
    
    
    
class="com.accucast4.testcase5.Recipient"    
/>    

Thanks.. 

 
Vivian Fonger
Software Engineer
Socketware
[EMAIL PROTECTED]
 


RE: [Hibernate] CVS Problems

2003-09-10 Thread Patrick Burleson


At 01:51 PM 9/10/2003 -0700, Schnitzer, Jeff wrote:
> From: Michael Gloegl [mailto:[EMAIL PROTECTED]
>
> when trying to connect to the CVS I constantly get "EOF from Server"
and
> "Connection Reset by Peer" errors. Is anyone else having such problems
> in the moment?
Yes.  I was getting them yesterday too.

(using anonymous cvs)

Jeff Schnitzer
[EMAIL PROTECTED]
I think it has to do with SF.net throttling the amount of pserver 
connections to the non-developer access CVS Server. I got it for a long 
time, and then I go through finally. It just takes time, keep trying.

Patrick 



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] CVS Problems

2003-09-10 Thread Warner Onstine
With a number of SF projects. It's been going on since yesterday 
morning.

-warner

On Wednesday, September 10, 2003, at 05:33 AM, Michael Gloegl wrote:

Hi everybody,

when trying to connect to the CVS I constantly get "EOF from Server" 
and "Connection Reset by Peer" errors. Is anyone else having such 
problems in the moment?

Michael



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] self-referential table

2003-09-10 Thread Warner Onstine
Got this working!

Now I have another question with regards to collections in general.

I tried to do this:
Set subCategories;
public void setSubCategories()
public Set getSubCategories()
public void addSubCategory()
public void removeSubCategory()
in add and remove I refer to the collection subCategories.add(subCat) 
and inversely for remove. When I put this through my test class it spit 
up a nasty reflection error so I went back to using the 
setSubCategories() instead and everything worked alright.

It would be nice to have a helper method like this defined in my class, 
is it possible with Hibernate though?

Thanks,
Warner
On Wednesday, September 10, 2003, at 08:26 AM, 
[EMAIL PROTECTED] wrote:

On Tuesday, September 9, 2003, at 07:07 PM, Gavin King wrote:

Theres nothing particularly special about this. Just map it as you 
would any other association.

The only problem is your -1, which breaks referential integrity of 
the whole table! just switch to using an SQL null.
Ok, I guess this is where I'm having a problem. How do I map this like 
any other association? BTW - I'm using Xdoclet for my mapping 
generation.

Here's what I defined for my collection:
  



   
  
  
  

Thanks for the assistance.

-warner

[EMAIL PROTECTED] wrote:

Alright, so I've searched all over the web (this list doesn't appear 
to be archived either), so here I am ;-).

I am finally getting into using Hibernate on a few projects and have 
run across something that I'm sure how it would be handled. I have 
one table that uses itself as a collection.

Basically the table looks like this:
create table Category (
   id VARCHAR(255) not null,
   parentid VARCHAR(255),
   name VARCHAR(255),
   description VARCHAR(255),
   primary key (id)
)
Where parentid is the parent of this category. If it's -1 then it's 
a root category (if there's a better way to do this please let me 
know.

What I'm unclear on is how to represent this in a mapping (and 
class-wise). I want to have a method getSubCategories which will 
return a set of Categories.

Thanks in advance,
Warner


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] Postgresql array index exception creating a new record

2003-09-10 Thread Gerry Duprey
Howdy,

I'm new to hibernate and have run into a problem almost immediatly in my test
program while trying to save a new object/record.  I've tried this with
Hibernate 2.0.3 and 2.1b3.  This is on PostreSQL7.
After creating a hibernatable object instance, I attempt to save it and close
the transaction.  When I do, I get an exception like this:
16:29:31,379 DEBUG BatcherImpl:24 - Adding to batch
16:29:31,381 DEBUG BatcherImpl:46 - Executing batch size: 1
16:29:31,423 ERROR BatcherImpl:62 - Exception executing batch:
java.lang.ArrayIndexOutOfBoundsException: 1
  at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:143)
  at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:65)
  at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:451)
  at
org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:281)
  at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)
  at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:179)
  at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:165)
  at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:80)
  at 
net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:50)
  at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:116)
  at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2281)

There is more and I can provide it if necessary.  The code for xreating and 
committing the
new record looks like:

Session theSession = theContext.getSession();
Transaction theTransaction = theSession.beginTransaction();
UserProfile baseUser = (UserProfile) theSession.load(UserProfile.class,
new Integer(1));
UserRole baseRole = (UserRole) theSession.load(UserRole.class, new
Integer(1));
DAOChangeNote changeNote = (DAOChangeNote)
DAOCommonFactory.getFactory().createChangeNote(baseUser);
UserProfile theUser = (UserProfile)
DAOCommonFactory.getFactory().createUserProfile();
theUser.setName(userName);
//theUser.setFullName(new Name());
theUser.setRole(baseRole);
theUser.setChangeNote(changeNote);
theSession.save(theUser);
theSession.flush();
theSession.commitTransaction();
The error occurs when I do the theSession.flush().  I'm pretty sure the
mappings are OK because I am able to load up other records of this same table
(the baseUser theSession.load() call) and it seems to work.
I realize there are probably hundreds of different places where this could be
going wrong.  If someone could suggest a few likely things to check,
I'd appreciate it.
Thanks much!

Gerry

--
Gerry Duprey

SchoolsOPEN, LLC
123 North Ashley, Suite 120
Ann Arbor, MI 48104
Phone (877) 483-1944 Ext. 401
Fax (734) 661-0819
Visit us Online at www.Schools-OPEN.com



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


RE: [Hibernate] Question on Session.connection

2003-09-10 Thread Chandrasekhar Ambadipudi

Thanks, it worked.

-Original Message-
From: Gavin King [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 10, 2003 11:21 AM
To: Chandrasekhar Ambadipudi
Cc: '[EMAIL PROTECTED]'
Subject: Re: [Hibernate] Question on Session.connection


Just call sess.flush() ... you can call it at any time :)

Chandrasekhar Ambadipudi wrote:

>   I have a  transaction like this
>
>   Transaction tx = sess.beginTransaction();
>   sess.save(obj)
>   sess.connection() // and  one prepared
>statment execution here
>   sess.update(obj1)
>   tx.commit();
>
>   How ever the sess.save() in line 2 and sess.update() in line 4 are
>getting executed at the time of commit when I call tx.commit().  but the
>prepared statement execution is done immediately, my prepared statement
>execution depends on sess.save() in line 2, but since line 2 and line 4 are
>executed after my line 3 related code Iam getting a foreign key exception
in
>my code, because by the time I execute linke number 3 here code assumes the
>line 2 has been executed and the entry has been made on the table.
>
>   Is there a way I can tell hibernate to execute line  2,3,4 in
>sequence and not to wait till tx.commit() or  other way can I can hint
>hibernate not to execute line 3 until commit time ?
>
>   Thanks
>   Chandra
>
>
>---
>This sf.net email is sponsored by:ThinkGeek
>Welcome to geek heaven.
>http://thinkgeek.com/sf
>___
>hibernate-devel mailing list
>[EMAIL PROTECTED]
>https://lists.sourceforge.net/lists/listinfo/hibernate-devel
>  
>


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] Postgresql array index exception creating a new record

2003-09-10 Thread Gavin King
I think it is a bug in the Postgres implementation of JDBC batch updates.

Gerry Duprey wrote:

Howdy,

I'm new to hibernate and have run into a problem almost immediatly in 
my test
program while trying to save a new object/record.  I've tried this with
Hibernate 2.0.3 and 2.1b3.  This is on PostreSQL7.

After creating a hibernatable object instance, I attempt to save it 
and close
the transaction.  When I do, I get an exception like this:

16:29:31,379 DEBUG BatcherImpl:24 - Adding to batch
16:29:31,381 DEBUG BatcherImpl:46 - Executing batch size: 1
16:29:31,423 ERROR BatcherImpl:62 - Exception executing batch:
java.lang.ArrayIndexOutOfBoundsException: 1
  at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:143)
  at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:65)
  at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:451) 

  at
org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:281) 

  at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48) 

  at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:179) 

  at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:165) 

  at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:80) 

  at 
net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:50) 

  at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:116)
  at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2281)
There is more and I can provide it if necessary.  The code for 
xreating and committing the
new record looks like:

Session theSession = theContext.getSession();
Transaction theTransaction = theSession.beginTransaction();
UserProfile baseUser = (UserProfile) 
theSession.load(UserProfile.class,
new Integer(1));
UserRole baseRole = (UserRole) theSession.load(UserRole.class, new
Integer(1));
DAOChangeNote changeNote = (DAOChangeNote)
DAOCommonFactory.getFactory().createChangeNote(baseUser);

UserProfile theUser = (UserProfile)
DAOCommonFactory.getFactory().createUserProfile();
theUser.setName(userName);
//theUser.setFullName(new Name());
theUser.setRole(baseRole);
theUser.setChangeNote(changeNote);
theSession.save(theUser);
theSession.flush();
theSession.commitTransaction();
The error occurs when I do the theSession.flush().  I'm pretty sure the
mappings are OK because I am able to load up other records of this 
same table
(the baseUser theSession.load() call) and it seems to work.

I realize there are probably hundreds of different places where this 
could be
going wrong.  If someone could suggest a few likely things to check,
I'd appreciate it.

Thanks much!

Gerry



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] self-referential table

2003-09-10 Thread Gavin King
Nope, the set/get are required.

Warner Onstine wrote:

Got this working!

Now I have another question with regards to collections in general.

I tried to do this:
Set subCategories;
public void setSubCategories()
public Set getSubCategories()
public void addSubCategory()
public void removeSubCategory()
in add and remove I refer to the collection subCategories.add(subCat) 
and inversely for remove. When I put this through my test class it 
spit up a nasty reflection error so I went back to using the 
setSubCategories() instead and everything worked alright.

It would be nice to have a helper method like this defined in my 
class, is it possible with Hibernate though?

Thanks,
Warner
On Wednesday, September 10, 2003, at 08:26 AM, 
[EMAIL PROTECTED] wrote:

On Tuesday, September 9, 2003, at 07:07 PM, Gavin King wrote:

Theres nothing particularly special about this. Just map it as you 
would any other association.

The only problem is your -1, which breaks referential integrity of 
the whole table! just switch to using an SQL null.


Ok, I guess this is where I'm having a problem. How do I map this 
like any other association? BTW - I'm using Xdoclet for my mapping 
generation.

Here's what I defined for my collection:
  




name="parentId"
type="string"
update="true"
insert="true"
column="parentid"
/>   
  
name="subCategories"
table="category"
lazy="false"
inverse="false"
cascade="all"
sort="unsorted"
>

  
  

Thanks for the assistance.

-warner

[EMAIL PROTECTED] wrote:

Alright, so I've searched all over the web (this list doesn't 
appear to be archived either), so here I am ;-).

I am finally getting into using Hibernate on a few projects and 
have run across something that I'm sure how it would be handled. I 
have one table that uses itself as a collection.

Basically the table looks like this:
create table Category (
   id VARCHAR(255) not null,
   parentid VARCHAR(255),
   name VARCHAR(255),
   description VARCHAR(255),
   primary key (id)
)
Where parentid is the parent of this category. If it's -1 then it's 
a root category (if there's a better way to do this please let me 
know.

What I'm unclear on is how to represent this in a mapping (and 
class-wise). I want to have a method getSubCategories which will 
return a set of Categories.

Thanks in advance,
Warner


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] What is the difference between version 2.0.3 and 2.1??

2003-09-10 Thread Gavin King
Should be 99.9% backward compatible. There are some "little" changes 
that might trip up a very small number of users, but they are mainly in 
the realm of "bugfixes".

Vivian Fonger wrote:

Hi everyone,
 
Can anyone give me the difference between version 2.0.3 and version 
2.1.?? Will I have any problem to upgrade from version 2.0.3 to 
version 2.1 when the version 2.1 becomes stable??
 
Vivian Fonger
Software Engineer
Socketware
[EMAIL PROTECTED] 
 




---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] self-referential table

2003-09-10 Thread jiesheng zhang
It definitely works. I have many such methods like
what you mentioned.
Post your method implementation and exception here.
Let me have a look.

jason



--- Warner Onstine <[EMAIL PROTECTED]> wrote:
> Got this working!
> 
> Now I have another question with regards to
> collections in general.
> 
> I tried to do this:
> Set subCategories;
> 
> public void setSubCategories()
> public Set getSubCategories()
> public void addSubCategory()
> public void removeSubCategory()
> 
> in add and remove I refer to the collection
> subCategories.add(subCat) 
> and inversely for remove. When I put this through my
> test class it spit 
> up a nasty reflection error so I went back to using
> the 
> setSubCategories() instead and everything worked
> alright.
> 
> It would be nice to have a helper method like this
> defined in my class, 
> is it possible with Hibernate though?
> 
> Thanks,
> Warner
> 


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel