You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Ivano Luberti <lu...@archicoop.it> on 2009/01/26 14:13:45 UTC

newbie question about postgres: nextval

Hello I have searched the net quite a lot but I have not been able to
find the answer to this problem.

I'm using postgres to generate torque classes but the automatic
generation seems to make a few mistakes.
In the base class I found this java statement

private int pkAnagrafica =
nextval('anagrafica_pk_anagrafica_seq'::regclass);

which is marked as wrong by the compiler.

The same happens in the copyobject method of the same class:

copyObj.setPkAnagrafica( nextval('anagrafica_pk_anagrafica_seq'::regclass));

Is there a way to stop Torque generating these bad statements ?

Thanks for your attention.



_
_ <http://www.archicoop.it/>__ <http://www.archicoop.it/>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: newbie question about postgres: nextval

Posted by Ivano Luberti <lu...@archicoop.it>.
Another little question about one of your suggestion.
Remeber I use jdbc task to generate chema.xml file from the db.


Greg Monroe ha scritto:
> In general, for autoincrement id fields coming out of the JDBC task, 
> you will need to decide which method to use with automatic id fields. 
> This is done via the defaultIdMethod attribute on the database tag  or 
> the idMethod attribute on the specific table tag.  The choices are 
> idbroker (Torque's works everywhere method), native (the DB server's 
> native method) or none.  In your case, you want native.
> Next you will need to identify the autoincrement fields and modify
> them to include the autoincrement="true" attribute and drop any
> default values.
>
>   
Ok, but what is the default value for defaultIdMethod and for idMethod ?
Moreover is there a way to tell JDBCTransformTask to put the right value
in the schema file ?
In other words: can jdbc task be configured to follow this behaviour ?


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: newbie question about postgres: nextval

Posted by Ivano Luberti <lu...@archicoop.it>.
I guess I need some aid in the field of comprehension ability: I tried
to start using hibernate a few times but I have never found the right
netry point in the docs, Torque has been really fast to learn at least
to produce the first classes and first code for CRUD operations.

Anyway, thanks again for your great help.


Thomas Fischer ha scritto:
>> Can you explaim why is so overwhelmed by Hibernate ? Is there some
>> performance related isssue ?
>>     
>
> My personal opinion is that there are two reasons:
> 1) documentation is _MUCH_ better for hibernate
> 2) The concept for hibernate seems to be easy: Give an object to Hibernate 
> and Hibernate does all the persistence work.
>
> But it not an performance issue. As you have total control over what the 
> database does, you have more optimisation potential in Torque than in 
> Hibernate. Maybe in some special cases it is more work to optimize Torque 
> application, but it is certainly feasible. 
>
>     Thomas
>   

-- 
==================================================
Archimede Informatica NEWS!
==================================================

Realizzato il Sistema Integrato per la biglietteria della Torre di Pisa:
prenotazione, vendita, pre-vendita ed emissione dei biglietti di ingresso
alla Torre sia online che presso le biglietterie dislocate sulla piazza:

_http://www.opapisa.it/boxoffice

_Partner del Progetto Ci-Tel "Front office Telematico per il cittadino"
Ente Coordinatore Comune di Pisa

_http://www.comune.pisa.it/doc/e-government.htm


_==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
e-mail: archimede@archicoop.it
web: _http://www.archicoop.it


_ <http://www.archicoop.it/>__ <http://www.archicoop.it/>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: newbie question about postgres: nextval

Posted by Thomas Vandahl <tv...@apache.org>.
Ivano Luberti wrote:
> Then, given your answer about the limitations of the jdbc task, I think
> that the absence of some visual tool that is able to produce this schema
> files is something  that prevents Torque to be more successful.
> For example if Power Architect would be able to generate both the schema
> file and not only the sql it would be great.

Well, the term "absence" this is not entirely true. We've got some
"special tools" to start with at
http://db.apache.org/torque/tools/index.html.

Many of the DB-Design-Tools use some kind of XML schema to store the db
model. So it's basically "just" a matter of writing a bit of XSLT...

On the other hand, the Torque database schema is used in a couple of
other projects, too.

Bye, Thomas.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: newbie question about postgres: nextval

Posted by Ivano Luberti <lu...@archicoop.it>.
Thank you Greg I have found the docs on schema files.
For what it worths, I will put my 2 cents on the Torque vs Hibernate matter.
Usually you don't want to overwrite your sql if you are not in the early
steps of db development: you change the DDL saving the data in some way.
The utility of software like torque is greater when you are in an
advanced stage of development and it saves a loto of time in modifying
java code.
Then, given your answer about the limitations of the jdbc task, I think
that the absence of some visual tool that is able to produce this schema
files is something  that prevents Torque to be more successful.
For example if Power Architect would be able to generate both the schema
file and not only the sql it would be great.






Greg Monroe ha scritto:
> FYI - Schema docs are under the Generator tab.  As to the 
> Torque vs Hibernate, I agree with what Thomas said and would 
> add the following:
>
> Hibernate is supported and "marketed" by Redhat/JBoss (a
> great deal initially, but now it's a community thing). In 
> addition, they designed it on better "buzz words". E.g., it's 
> Enterprise Middle-ware designed to let programmers implement 
> business logic that is supported be a variety of back-end 
> including full blown EJB application environments (like JBoss).
>
> By contrast, IMHO, Torque is designed as a RAD tool focused 
> on making JDBC simple for programmers.  So they can get on 
> with writing business logic and not worry about many of the
> fiddly persistence details. Not only that but it is designed
> to help make long term maintenance easier.  For example: by 
> using complier constants to help identify column name changes;
> A single XML schema file that can be updated as tables change
> and re-generate the access objects; and the like.
>
>   
>> -----Original Message-----
>> From: Thomas Fischer [mailto:fischer@seitenbau.net]
>> Sent: Monday, January 26, 2009 12:22 PM
>> To: Apache Torque Users List
>> Subject: Re: newbie question about postgres: nextval
>>
>>     
>>> Can you explaim why is so overwhelmed by Hibernate ? Is there some
>>> performance related isssue ?
>>>       
>> My personal opinion is that there are two reasons:
>> 1) documentation is _MUCH_ better for hibernate
>> 2) The concept for hibernate seems to be easy: Give an object to
>> Hibernate
>> and Hibernate does all the persistence work.
>>
>> But it not an performance issue. As you have total control over what the
>> database does, you have more optimisation potential in Torque than in
>> Hibernate. Maybe in some special cases it is more work to optimize Torque
>> application, but it is certainly feasible.
>>
>>     Thomas
>>     
> DukeCE Privacy Statement:
> Please be advised that this e-mail and any files transmitted with
> it are confidential communication or may otherwise be privileged or
> confidential and are intended solely for the individual or entity
> to whom they are addressed. If you are not the intended recipient
> you may not rely on the contents of this email or any attachments,
> and we ask that you please not read, copy or retransmit this
> communication, but reply to the sender and destroy the email, its
> contents, and all copies thereof immediately. Any unauthorized
> dissemination, distribution or copying of this communication is
> strictly prohibited.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>
>   

-- 
==================================================
Archimede Informatica NEWS!
==================================================

Realizzato il Sistema Integrato per la biglietteria della Torre di Pisa:
prenotazione, vendita, pre-vendita ed emissione dei biglietti di ingresso
alla Torre sia online che presso le biglietterie dislocate sulla piazza:

_http://www.opapisa.it/boxoffice

_Partner del Progetto Ci-Tel "Front office Telematico per il cittadino"
Ente Coordinatore Comune di Pisa

_http://www.comune.pisa.it/doc/e-government.htm


_==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
e-mail: archimede@archicoop.it
web: _http://www.archicoop.it


_ <http://www.archicoop.it/>__ <http://www.archicoop.it/>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


RE: newbie question about postgres: nextval

Posted by Greg Monroe <mo...@dukece.com>.
FYI - Schema docs are under the Generator tab.  As to the 
Torque vs Hibernate, I agree with what Thomas said and would 
add the following:

Hibernate is supported and "marketed" by Redhat/JBoss (a
great deal initially, but now it's a community thing). In 
addition, they designed it on better "buzz words". E.g., it's 
Enterprise Middle-ware designed to let programmers implement 
business logic that is supported be a variety of back-end 
including full blown EJB application environments (like JBoss).

By contrast, IMHO, Torque is designed as a RAD tool focused 
on making JDBC simple for programmers.  So they can get on 
with writing business logic and not worry about many of the
fiddly persistence details. Not only that but it is designed
to help make long term maintenance easier.  For example: by 
using complier constants to help identify column name changes;
A single XML schema file that can be updated as tables change
and re-generate the access objects; and the like.

> -----Original Message-----
> From: Thomas Fischer [mailto:fischer@seitenbau.net]
> Sent: Monday, January 26, 2009 12:22 PM
> To: Apache Torque Users List
> Subject: Re: newbie question about postgres: nextval
> 
> > Can you explaim why is so overwhelmed by Hibernate ? Is there some
> > performance related isssue ?
> 
> My personal opinion is that there are two reasons:
> 1) documentation is _MUCH_ better for hibernate
> 2) The concept for hibernate seems to be easy: Give an object to
> Hibernate
> and Hibernate does all the persistence work.
> 
> But it not an performance issue. As you have total control over what the
> database does, you have more optimisation potential in Torque than in
> Hibernate. Maybe in some special cases it is more work to optimize Torque
> application, but it is certainly feasible.
> 
>     Thomas
DukeCE Privacy Statement:
Please be advised that this e-mail and any files transmitted with
it are confidential communication or may otherwise be privileged or
confidential and are intended solely for the individual or entity
to whom they are addressed. If you are not the intended recipient
you may not rely on the contents of this email or any attachments,
and we ask that you please not read, copy or retransmit this
communication, but reply to the sender and destroy the email, its
contents, and all copies thereof immediately. Any unauthorized
dissemination, distribution or copying of this communication is
strictly prohibited.

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Antwort: Re: newbie question about postgres: nextval

Posted by Thomas Fischer <fi...@seitenbau.net>.
> > My personal opinion is that there are two reasons:
> > 1) documentation is _MUCH_ better for hibernate
> > 2) The concept for hibernate seems to be easy: Give an object to 
Hibernate 
> > and Hibernate does all the persistence work.
> 
> I'd like to add that I tend to disagree with the point "easy concept".
> If you wrote those mapping xml-files once you'd know what I mean.
> 
> What I like best about Torque is the generator approach. It puts a
> compiler between me and my database objects and this alone helps a lot
> to find problems with the schema (as Ivano has experienced). Hibernate
> on the contrary uses introspection to handle its objects which is a PITA
> to debug. Just look at the zillions of Hibernate tools to help you with
> a problem you'd never have if you did it right in the first place...

That is why I wrote the word "seems" :-)
I am just now doing a project with hibernate (I was forced to use it) and 
am having exactly the same problem as Thomas describes. But it is a good 
thing to see the problems of other tools; one appreciates more what one 
has got.

    Thomas

Re: newbie question about postgres: nextval

Posted by Thomas Vandahl <tv...@apache.org>.
Thomas Fischer wrote:
>> Can you explaim why is so overwhelmed by Hibernate ? Is there some
>> performance related isssue ?
> 
> My personal opinion is that there are two reasons:
> 1) documentation is _MUCH_ better for hibernate
> 2) The concept for hibernate seems to be easy: Give an object to Hibernate 
> and Hibernate does all the persistence work.

I'd like to add that I tend to disagree with the point "easy concept".
If you wrote those mapping xml-files once you'd know what I mean.

What I like best about Torque is the generator approach. It puts a
compiler between me and my database objects and this alone helps a lot
to find problems with the schema (as Ivano has experienced). Hibernate
on the contrary uses introspection to handle its objects which is a PITA
to debug. Just look at the zillions of Hibernate tools to help you with
a problem you'd never have if you did it right in the first place...

Just my two cents.

Bye, Thomas.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: newbie question about postgres: nextval

Posted by Thomas Fischer <fi...@seitenbau.net>.
> Can you explaim why is so overwhelmed by Hibernate ? Is there some
> performance related isssue ?

My personal opinion is that there are two reasons:
1) documentation is _MUCH_ better for hibernate
2) The concept for hibernate seems to be easy: Give an object to Hibernate 
and Hibernate does all the persistence work.

But it not an performance issue. As you have total control over what the 
database does, you have more optimisation potential in Torque than in 
Hibernate. Maybe in some special cases it is more work to optimize Torque 
application, but it is certainly feasible. 

    Thomas

Re: newbie question about postgres: nextval

Posted by Ivano Luberti <lu...@archicoop.it>.
Greg, thanks for your answer really exhaustive.
But then where I can find a reference for the schmea file , so that I
can change or add all the db information I need ?

This ml seems really supportive: since Torque seems no more progressing
since 2007 I was fearing there was no actrivity on the list expecially
made by expert.

At this moment I'm really satisfied of Torque: I'm start using Torque
because I became familiar with its php porting (propel) and found it
really easy to use.
Can you explaim why is so overwhelmed by Hibernate ? Is there some
performance related isssue ?




Greg Monroe ha scritto:
> OK, the part about the jdbc task clears a lot up.  This task does
> the best it can using the standard meta info supplied by the 
> JDBC drivers.  Since this is a standard across all the various
> DB server types, there are some limitations when it comes to various
> "pseudo" standards that Torque supports, like native autoincrement 
> fields (and offset and limit to name some others).
>
> Native autoincrement is actually not an SQL standard.  However, since 
> most DB servers have a method of autoincrementing fields built in and 
> auto-incrementing index fields is commonly used in existing schemas, 
> Torque supports this "pseudo" standard in its runtime and SQL creation.
> But since this is implemented and reported very differently by all the
> JDBC drivers (if at all), the JDBC task can't create the correct XML
> given the information available.
>
> This is what is causing your problems.  The bottom line is that the 
> JDBC task output should always be considered a starting point that
> will need to be refined to match the actual schema needs.
>
> In general, for autoincrement id fields coming out of the JDBC task, 
> you will need to decide which method to use with automatic id fields. 
> This is done via the defaultIdMethod attribute on the database tag  or 
> the idMethod attribute on the specific table tag.  The choices are 
> idbroker (Torque's works everywhere method), native (the DB server's 
> native method) or none.  In your case, you want native.
>
> Next you will need to identify the autoincrement fields and modify
> them to include the autoincrement="true" attribute and drop any
> default values.
>
> FWIW, some other "gotchas" from the JDBC task that come to mind are:
>
> If you care about creating the tables via Torque, this does not 
> create any Index or Unique information (JDBC doesn't supply this).  
> You will have to add these in manually.
>
> The table ordering may not meet the requirement that foreign keys
> be defined prior to their use.  So you may need to move some 
> table definitions around to make sure the tables with keys come
> first.
>
> It sounds like a lot of work, but in general, it takes only a
> few minutes (or can be automated for your specific DB standard).
> Just remember that this is a small amount of time compared to what 
> it would take to write all the code that gets generated.
>
>
>
>
>   
>> -----Original Message-----
>> From: Ivano Luberti [mailto:luberti@archicoop.it]
>> Sent: Monday, January 26, 2009 10:15 AM
>> To: Apache Torque Users List
>> Subject: Re: newbie question about postgres: nextval
>>
>> Here it is .
>> In my prev message I didn't said that , I have defined the db using the
>> server , then I have generated the schema using the jdbc ant task and the
>> classes using the om ant task.
>> I don't want to define myself the shema file because I'm more famliar
>> with SQL and then I don't want to make Torque create or modify my DDL.
>> Finally I use Torque 3.3 version and the generator directly without using
>> Maven.
>>
>>
>>
>> Thomas Fischer ha scritto:
>>     
>>>> I'm using postgres to generate torque classes but the automatic
>>>> generation seems to make a few mistakes.
>>>> In the base class I found this java statement
>>>>
>>>> private int pkAnagrafica =
>>>> nextval('anagrafica_pk_anagrafica_seq'::regclass);
>>>>
>>>> which is marked as wrong by the compiler.
>>>>
>>>> The same happens in the copyobject method of the same class:
>>>>
>>>> copyObj.setPkAnagrafica(
>>>>
>>>>         
>>> nextval('anagrafica_pk_anagrafica_seq'::regclass));
>>>
>>>       
>>>> Is there a way to stop Torque generating these bad statements ?
>>>>
>>>>         
>>> Can you send the schema definition which you use for the table in
>>> question ? This would ease diagnostics. I suspect that you use a
>>> default value for the id; this is not necessary.
>>>
>>>    Thomas
>>>
>>>       
>> --
>> ==================================================
>> Archimede Informatica NEWS!
>> ==================================================
>>
>> Realizzato il Sistema Integrato per la biglietteria della Torre di Pisa:
>> prenotazione, vendita, pre-vendita ed emissione dei biglietti di ingresso
>> alla Torre sia online che presso le biglietterie dislocate sulla piazza:
>>
>> _http://www.opapisa.it/boxoffice
>>
>> _Partner del Progetto Ci-Tel "Front office Telematico per il cittadino"
>> Ente Coordinatore Comune di Pisa
>>
>> _http://www.comune.pisa.it/doc/e-government.htm
>>
>>
>> _==================================================
>> dott. Ivano Mario Luberti
>> Archimede Informatica societa' cooperativa a r. l.
>> Sede Operativa
>> Via Gereschi 36 - 56126- Pisa
>> tel.: +39-050- 580959
>> tel/fax: +39-050-9711344
>> e-mail: archimede@archicoop.it
>> web: _http://www.archicoop.it
>>
>>
>> _ <http://www.archicoop.it/>__ <http://www.archicoop.it/>
>>     
> DukeCE Privacy Statement:
> Please be advised that this e-mail and any files transmitted with
> it are confidential communication or may otherwise be privileged or
> confidential and are intended solely for the individual or entity
> to whom they are addressed. If you are not the intended recipient
> you may not rely on the contents of this email or any attachments,
> and we ask that you please not read, copy or retransmit this
> communication, but reply to the sender and destroy the email, its
> contents, and all copies thereof immediately. Any unauthorized
> dissemination, distribution or copying of this communication is
> strictly prohibited.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>
>   

-- 
==================================================
Archimede Informatica NEWS!
==================================================

Realizzato il Sistema Integrato per la biglietteria della Torre di Pisa:
prenotazione, vendita, pre-vendita ed emissione dei biglietti di ingresso
alla Torre sia online che presso le biglietterie dislocate sulla piazza:

_http://www.opapisa.it/boxoffice

_Partner del Progetto Ci-Tel "Front office Telematico per il cittadino"
Ente Coordinatore Comune di Pisa

_http://www.comune.pisa.it/doc/e-government.htm


_==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
e-mail: archimede@archicoop.it
web: _http://www.archicoop.it


_ <http://www.archicoop.it/>__ <http://www.archicoop.it/>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


RE: newbie question about postgres: nextval

Posted by Greg Monroe <mo...@dukece.com>.
OK, the part about the jdbc task clears a lot up.  This task does
the best it can using the standard meta info supplied by the 
JDBC drivers.  Since this is a standard across all the various
DB server types, there are some limitations when it comes to various
"pseudo" standards that Torque supports, like native autoincrement 
fields (and offset and limit to name some others).

Native autoincrement is actually not an SQL standard.  However, since 
most DB servers have a method of autoincrementing fields built in and 
auto-incrementing index fields is commonly used in existing schemas, 
Torque supports this "pseudo" standard in its runtime and SQL creation.
But since this is implemented and reported very differently by all the
JDBC drivers (if at all), the JDBC task can't create the correct XML
given the information available.

This is what is causing your problems.  The bottom line is that the 
JDBC task output should always be considered a starting point that
will need to be refined to match the actual schema needs.

In general, for autoincrement id fields coming out of the JDBC task, 
you will need to decide which method to use with automatic id fields. 
This is done via the defaultIdMethod attribute on the database tag  or 
the idMethod attribute on the specific table tag.  The choices are 
idbroker (Torque's works everywhere method), native (the DB server's 
native method) or none.  In your case, you want native.

Next you will need to identify the autoincrement fields and modify
them to include the autoincrement="true" attribute and drop any
default values.

FWIW, some other "gotchas" from the JDBC task that come to mind are:

If you care about creating the tables via Torque, this does not 
create any Index or Unique information (JDBC doesn't supply this).  
You will have to add these in manually.

The table ordering may not meet the requirement that foreign keys
be defined prior to their use.  So you may need to move some 
table definitions around to make sure the tables with keys come
first.

It sounds like a lot of work, but in general, it takes only a
few minutes (or can be automated for your specific DB standard).
Just remember that this is a small amount of time compared to what 
it would take to write all the code that gets generated.




> -----Original Message-----
> From: Ivano Luberti [mailto:luberti@archicoop.it]
> Sent: Monday, January 26, 2009 10:15 AM
> To: Apache Torque Users List
> Subject: Re: newbie question about postgres: nextval
> 
> Here it is .
> In my prev message I didn't said that , I have defined the db using the
> server , then I have generated the schema using the jdbc ant task and the
> classes using the om ant task.
> I don't want to define myself the shema file because I'm more famliar
> with SQL and then I don't want to make Torque create or modify my DDL.
> Finally I use Torque 3.3 version and the generator directly without using
> Maven.
> 
> 
> 
> Thomas Fischer ha scritto:
> >> I'm using postgres to generate torque classes but the automatic
> >> generation seems to make a few mistakes.
> >> In the base class I found this java statement
> >>
> >> private int pkAnagrafica =
> >> nextval('anagrafica_pk_anagrafica_seq'::regclass);
> >>
> >> which is marked as wrong by the compiler.
> >>
> >> The same happens in the copyobject method of the same class:
> >>
> >> copyObj.setPkAnagrafica(
> >>
> > nextval('anagrafica_pk_anagrafica_seq'::regclass));
> >
> >> Is there a way to stop Torque generating these bad statements ?
> >>
> >
> > Can you send the schema definition which you use for the table in
> > question ? This would ease diagnostics. I suspect that you use a
> > default value for the id; this is not necessary.
> >
> >    Thomas
> >
> 
> --
> ==================================================
> Archimede Informatica NEWS!
> ==================================================
> 
> Realizzato il Sistema Integrato per la biglietteria della Torre di Pisa:
> prenotazione, vendita, pre-vendita ed emissione dei biglietti di ingresso
> alla Torre sia online che presso le biglietterie dislocate sulla piazza:
> 
> _http://www.opapisa.it/boxoffice
> 
> _Partner del Progetto Ci-Tel "Front office Telematico per il cittadino"
> Ente Coordinatore Comune di Pisa
> 
> _http://www.comune.pisa.it/doc/e-government.htm
> 
> 
> _==================================================
> dott. Ivano Mario Luberti
> Archimede Informatica societa' cooperativa a r. l.
> Sede Operativa
> Via Gereschi 36 - 56126- Pisa
> tel.: +39-050- 580959
> tel/fax: +39-050-9711344
> e-mail: archimede@archicoop.it
> web: _http://www.archicoop.it
> 
> 
> _ <http://www.archicoop.it/>__ <http://www.archicoop.it/>
DukeCE Privacy Statement:
Please be advised that this e-mail and any files transmitted with
it are confidential communication or may otherwise be privileged or
confidential and are intended solely for the individual or entity
to whom they are addressed. If you are not the intended recipient
you may not rely on the contents of this email or any attachments,
and we ask that you please not read, copy or retransmit this
communication, but reply to the sender and destroy the email, its
contents, and all copies thereof immediately. Any unauthorized
dissemination, distribution or copying of this communication is
strictly prohibited.

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: newbie question about postgres: nextval

Posted by Ivano Luberti <lu...@archicoop.it>.
Ok, now I understand why someone has choosen to change the java code of
the JDBC ant task (found it on some mailing list) !

Thomas Fischer ha scritto:
> I am surprised that the jdbc task recognizes foreign keys ? Or did you add 
> the foreign-key elements yourself ?
>
>        Thomas
>   
No the foreign key have been recognized by the task.
I knew there was an issue with that but maybe the changes in postgres
8.3 have met the  the java code ?
 


_
_ <http://www.archicoop.it/>__ <http://www.archicoop.it/>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: newbie question about postgres: nextval

Posted by Thomas Fischer <fi...@seitenbau.net>.
> In my prev message I didn't said that , I have defined the db using the
> server , then I have generated the schema using the jdbc ant task and
> the classes using the om ant task.
> I don't want to define myself the shema file because I'm more famliar
> with SQL and then I don't want to make Torque create or modify my DDL.

The schema generated via the ant task can only serve as a starting point, 
because Torque uses only the information the jdbc driver provides. This 
means e.g. it does not automatically detect the method the id is 
generated, or it can mess up the default values.

So you need to fine-tune the schema generated by the jdbc task. In your 
case, set the attribute defaultIdMethod to "native" on the database 
element (this will give you id generation by sequences in postgresql), and 
remove the attributes named "default" on the column elements. However, I 
do not know out of the box how to influence the sequence names which are 
expected by torque, it would be easiest if the sequences would have the 
default name (for these check the ddl generated by torque)

I am surprised that the jdbc task recognizes foreign keys ? Or did you add 
the foreign-key elements yourself ?

       Thomas

Re: newbie question about postgres: nextval

Posted by Ivano Luberti <lu...@archicoop.it>.
Here it is .
In my prev message I didn't said that , I have defined the db using the
server , then I have generated the schema using the jdbc ant task and
the classes using the om ant task.
I don't want to define myself the shema file because I'm more famliar
with SQL and then I don't want to make Torque create or modify my DDL.
Finally I use Torque 3.3 version and the generator directly without
using Maven.



Thomas Fischer ha scritto:
>> I'm using postgres to generate torque classes but the automatic
>> generation seems to make a few mistakes.
>> In the base class I found this java statement
>>
>> private int pkAnagrafica =
>> nextval('anagrafica_pk_anagrafica_seq'::regclass);
>>
>> which is marked as wrong by the compiler.
>>
>> The same happens in the copyobject method of the same class:
>>
>> copyObj.setPkAnagrafica( 
>>     
> nextval('anagrafica_pk_anagrafica_seq'::regclass));
>   
>> Is there a way to stop Torque generating these bad statements ?
>>     
>
> Can you send the schema definition which you use for the table in question 
> ? This would ease diagnostics. I suspect that you use a default value for 
> the id; this is not necessary.
>
>    Thomas
>   

-- 
==================================================
Archimede Informatica NEWS!
==================================================

Realizzato il Sistema Integrato per la biglietteria della Torre di Pisa:
prenotazione, vendita, pre-vendita ed emissione dei biglietti di ingresso
alla Torre sia online che presso le biglietterie dislocate sulla piazza:

_http://www.opapisa.it/boxoffice

_Partner del Progetto Ci-Tel "Front office Telematico per il cittadino"
Ente Coordinatore Comune di Pisa

_http://www.comune.pisa.it/doc/e-government.htm


_==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
e-mail: archimede@archicoop.it
web: _http://www.archicoop.it


_ <http://www.archicoop.it/>__ <http://www.archicoop.it/>

RE: newbie question about postgres: nextval

Posted by Thomas Fischer <fi...@seitenbau.net>.
> I'm using postgres to generate torque classes but the automatic
> generation seems to make a few mistakes.
> In the base class I found this java statement
> 
> private int pkAnagrafica =
> nextval('anagrafica_pk_anagrafica_seq'::regclass);
> 
> which is marked as wrong by the compiler.
> 
> The same happens in the copyobject method of the same class:
> 
> copyObj.setPkAnagrafica( 
nextval('anagrafica_pk_anagrafica_seq'::regclass));
> 
> Is there a way to stop Torque generating these bad statements ?

Can you send the schema definition which you use for the table in question 
? This would ease diagnostics. I suspect that you use a default value for 
the id; this is not necessary.

   Thomas