Problem with log4j

2005-10-06 Thread Marco Berri

Hi!

My application using ibatis 2.1.5.582

Ibatis NOT WRITE LOG INFORMATIONS!!

PLEASE HELP ME 

Marco Berri


Using: log4j 1.2.11

log4j.xml :


?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE log4j:configuration SYSTEM log4j.dtd

log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/;


 appender name=tnes-fat-mail 
class=org.apache.log4j.net.SMTPAppender
param name=Threshold value=FATAL/   
param name=SMTPHost value=${org.tnes.log.smtp}/
param name=To value=${org.tnes.log.mailto}/
param name=From value=${org.tnes.log.mailfrom}/
param name=Subject value=${org.tnes.log.mailsubject}/
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%-5p [%d{-MM-dd 
HH:mm:ss}] %x %c [%l] \n %m%n/

/layout
/appender


appender name=com-ibatis 
class=org.apache.log4j.RollingFileAppender
param name=File value=usr/local/ibatis/ibatis.log /
param name=MaxFileSize value=1MB/
param name=MaxBackupIndex value=5/
layout class=org.apache.log4j.PatternLayout
	param name=ConversionPattern value=%-5p [%d{-MM-dd 
HH:mm:ss}] %x %c [%l] - %m%n/

/layout
/appender

 logger name=com.ibatis additivity=true
 level value=ALL/
   appender-ref ref=com-ibatis /
/logger

root
level value=fatal/
appender-ref ref=tnes-fat-mail /
/root



/log4j:configuration



Getting connection from ibatis

2005-10-06 Thread Agilan Palani








Hi



Iam using ibatis in my project, with
JBoss application server.

 

I have some taglibs from oracle which
uploads ORDImages (Oracle specific objects) to the database

ord:storeMedia 

These tags either need a connection
or datasource, passed as one of its argument to perform its task.

Those tags will take care of committing
and closing the connections. 



Q1. How do I get the connection from
IBATIS?

Q2. How do I get the datasource from
IBATIS?



 Any help will be very useful, thanks in advance.



Regards

Agilan Palani








RE: Problem with log4j

2005-10-06 Thread Agilan Palani
Change your xml as shown below and try

 logger name=com.ibatis additivity=true
 level value=debug/
appender-ref ref=com-ibatis /
/logger

root
level value=debug/
appender-ref ref=tnes-fat-mail /
/root


Regards
Agilan Palani

-Original Message-
From: Marco Berri [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 06, 2005 4:51 PM
To: user-java@ibatis.apache.org
Subject: Problem with log4j

Hi!

My application using ibatis 2.1.5.582

Ibatis NOT WRITE LOG INFORMATIONS!!

PLEASE HELP ME 

Marco Berri


Using: log4j 1.2.11

log4j.xml :


?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE log4j:configuration SYSTEM log4j.dtd

log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/;


 appender name=tnes-fat-mail
class=org.apache.log4j.net.SMTPAppender
param name=Threshold value=FATAL/ 
param name=SMTPHost value=${org.tnes.log.smtp}/
param name=To value=${org.tnes.log.mailto}/
param name=From value=${org.tnes.log.mailfrom}/
param name=Subject value=${org.tnes.log.mailsubject}/
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%-5p
[%d{-MM-dd 
HH:mm:ss}] %x %c [%l] \n %m%n/
/layout
/appender


appender name=com-ibatis
class=org.apache.log4j.RollingFileAppender
param name=File value=usr/local/ibatis/ibatis.log /
param name=MaxFileSize value=1MB/
param name=MaxBackupIndex value=5/
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%-5p
[%d{-MM-dd 
HH:mm:ss}] %x %c [%l] - %m%n/
/layout
 /appender

 logger name=com.ibatis additivity=true
 level value=ALL/
appender-ref ref=com-ibatis /
/logger

root
level value=fatal/
appender-ref ref=tnes-fat-mail /
/root



/log4j:configuration



Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

2005-10-06 Thread Clinton Begin

If you are seriously worried about 220ms of time in an enterprise
aplication, then iBATIS (and all other frameworks) are not for
you. Stick with JDBC.

Performance testing enterprise applications is very complex, and you
should avoid drawing conclusions based on simple tests of 10 executions
of a single SQL statement.

Have you tested Struts compared to plain Servlets and JSP?

Cheers,
ClintonOn 10/5/05, Rodrigo Castillo [EMAIL PROTECTED] wrote:
Hi,I built two testing over framwork ibatis, I had used JdbcDaoTemplate andSqlMapDaoTemplate both implement the same query, the JDBC drivers is oracle.1) JdbcDaoTemplatethe average of method execute()is 80ms (with 10 execution)
2)SqlMapDaoTemplatethe average of method execute()is 300ms (with 10 execution) classcom.ibatis.sqlmap.engine.execution.SqlExecutorwhy the method execute() of SqlMapDaoTemplateis slower than Jdbc if it is
using the same framework?--source JdbcDaoTemplate--public class TestingJDBCDAO extends JdbcDaoTemplate implements TestingPLDAO{
public TestingJDBCDAO (DaoManager daoManager) {super(daoManager);}public List findBookingByFlightJDBC(FlightDBO flight) { Collectionresult = new ArrayList(); try {
 Connection conn = getConnection(); // Llamada a PL para buscar listado de vuelos. int index = 1; StringBuffer call = new StringBuffer(); call.append
(select * from book b, vlbk v ); call.append( where b.prbk_seq_cdg = v.prbk_seq_cdg ); call.append(and v.lnar_cdg_iata=?); call.append(and 
v.vlos_cdg=?); call.append(and v.vlos_fch=to_date(?,'dd/mm/') ); call.append(and v.vlbk_origen=? ); call.append(and v.vlbk_destino =? );
 // Crear statement y agregarlo a 'closer'. PreparedStatement cstmt = conn.prepareStatement(call.toString()); // Se Asignan parámetros para el PL. cstmt.setString
( index++, flight.getIataCode()); // 1 cstmt.setLong(index++, flight.getFlightNumber().longValue()); // 2 SimpleDate fecha = new SimpleDate(flight.getFlightDate()); cstmt.setString
(index++, fecha.toString(dd/MM/) ); // 3 cstmt.setString( index++, flight.getFlightOrigin()); // 4 cstmt.setString( index++, flight.getFlightDestination()); // 5 LapseMeter l= new LapseMeter();
cstmt.execute();//
Ejecuta el PL.System.out.println(time execute+l.lapse());
ResultSet rs = cstmt.getResultSet();// Ejecuta
el PL. // Obtiene cursor con los registros. BookingDBO booking = null; while ( rs.next()) { booking = new BookingDBO();
booking.setBookingCode(new Long(rs.getLong(prbk_seq_cdg)));
booking.setCompanyCode(new Long(rs.getLong(book_empr_cdg)));
booking.setAirlineCode(rs.getString(lnar_cdg_iata));
booking.setStatus(rs.getString(esbk_cdg_estd));
booking.setBookingType(rs.getString(tpbk_cdg_booking));
booking.setDocumentType(rs.getString(tdoc_cdg));
booking.setUser(rs.getString(book_usuario));
booking.setUserOffice(rs.getString(book_ofcn_usuario));
booking.setDocumentOrigin(rs.getString(book_origen_doc)); booking.setDocumentDestination(rs.getString(book_destino_doc));
booking.setFlightOrigin(rs.getString(book_origen_vuelo)); booking.setFlightDestination(rs.getString(book_destino_vuelo)); //booking.setCreationDate( getSimpleDate
(rs,book_fecha_gen).toDate() ); //booking.setFlightDate( getSimpleDate(rs,book_fecha_embarque).toDate() );
booking.setDocumentPrefix(new Long(rs.getLong(book_pref_doc )));
booking.setDocumentNumber(new Long(rs.getLong(book_num_doc )));
booking.setAgentCode(new Long(rs.getLong(book_clhl_cdg)));
booking.setAgentBranchCode(new Long(rs.getLong(book_clhl_scrs))); booking.setAgentContactName(rs.getString(book_contacto_agente)); booking.setAgentContactPhone
(rs.getString(book_fono_contacto)); booking.setShipperCode(new Long(rs.getLong(book_cdg_shipper)));
booking.setShipperBranchCode(new Long(rs.getLong(book_scrs_shipper)));
booking.setShipperName(rs.getString(book_nmb_shipper));
booking.setConsigneeCode(new Long(rs.getLong(book_cdg_consignee)));
booking.setConsigneeName(rs.getString(book_nmb_consignee));
booking.setConsigneeBranchCode(new Long(rs.getLong(book_scrs_consignee)));
booking.setAverageRate(new Double(rs.getDouble(book_tarifa)));
booking.setRemarks(rs.getString(book_remarks));
booking.setTotalWeight(new Double(rs.getDouble(book_gross)));
booking.setChargeableWeight(new Double(rs.getDouble(book_chargeable)));
booking.setTotalVolume(new Double(rs.getDouble(book_volumen_total))); booking.setTotalPieces(new Long(rs.getLong(book_total_piezas)));
booking.setAgentName(rs.getString(book_nmb_agente));
booking.setAgentAcronym(rs.getString(book_acronimo_agente)); booking.setShipperAcronym(rs.getString(book_acronimo_shipper)); booking.setConsigneeAcronym(rs.getString
(book_acronimo_consignee));
booking.setContractId(rs.getString(cnto_id)); booking.setContractRateType(rs.getString(book_contrato_allocation)); result.add(booking); }
 } catch (Exception x) { x.printStackTrace(); } return (List)result; }---Source 

Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

2005-10-06 Thread Clinton Begin

PS: We cannot acknowledge performance test results, nor can we
answer questions or do anything about them -- unless you post your test
code including database scripts and platform details.

Cheers,
ClintonOn 10/6/05, Clinton Begin [EMAIL PROTECTED] wrote:

If you are seriously worried about 220ms of time in an enterprise
aplication, then iBATIS (and all other frameworks) are not for
you. Stick with JDBC.

Performance testing enterprise applications is very complex, and you
should avoid drawing conclusions based on simple tests of 10 executions
of a single SQL statement.

Have you tested Struts compared to plain Servlets and JSP?

Cheers,
ClintonOn 10/5/05, Rodrigo Castillo 
[EMAIL PROTECTED] wrote:
Hi,I built two testing over framwork ibatis, I had used JdbcDaoTemplate andSqlMapDaoTemplate both implement the same query, the JDBC drivers is oracle.1) JdbcDaoTemplatethe average of method execute()is 80ms (with 10 execution)
2)SqlMapDaoTemplatethe average of method execute()is 300ms (with 10 execution) classcom.ibatis.sqlmap.engine.execution.SqlExecutorwhy the method execute() of SqlMapDaoTemplateis slower than Jdbc if it is
using the same framework?--source JdbcDaoTemplate--public class TestingJDBCDAO extends JdbcDaoTemplate implements TestingPLDAO{
public TestingJDBCDAO (DaoManager daoManager) {super(daoManager);}public List findBookingByFlightJDBC(FlightDBO flight) { Collectionresult = new ArrayList(); try {
 Connection conn = getConnection(); // Llamada a PL para buscar listado de vuelos. int index = 1; StringBuffer call = new StringBuffer(); 
call.append
(select * from book b, vlbk v ); call.append( where b.prbk_seq_cdg = v.prbk_seq_cdg ); call.append(and v.lnar_cdg_iata=?); call.append(and 
v.vlos_cdg=?); call.append(and v.vlos_fch=to_date(?,'dd/mm/') ); call.append(and v.vlbk_origen=? ); call.append(and v.vlbk_destino =? );
 // Crear statement y agregarlo a 'closer'. PreparedStatement cstmt = conn.prepareStatement(call.toString()); // Se Asignan parámetros para el PL. cstmt.setString

( index++, flight.getIataCode()); // 1 cstmt.setLong(index++, flight.getFlightNumber().longValue()); // 2 SimpleDate fecha = new SimpleDate(flight.getFlightDate()); cstmt.setString

(index++, fecha.toString(dd/MM/) ); // 3 cstmt.setString( index++, flight.getFlightOrigin()); // 4 cstmt.setString( index++, flight.getFlightDestination()); // 5 LapseMeter l= new LapseMeter();
cstmt.execute();//
Ejecuta el PL.System.out.println(time execute+l.lapse());
ResultSet rs = cstmt.getResultSet();// Ejecuta
el PL. // Obtiene cursor con los registros. BookingDBO booking = null; while ( rs.next()) { booking = new BookingDBO();
booking.setBookingCode(new Long(rs.getLong(prbk_seq_cdg)));
booking.setCompanyCode(new Long(rs.getLong(book_empr_cdg)));
booking.setAirlineCode(rs.getString(lnar_cdg_iata));
booking.setStatus(rs.getString(esbk_cdg_estd));
booking.setBookingType(rs.getString(tpbk_cdg_booking));
booking.setDocumentType(rs.getString(tdoc_cdg));
booking.setUser(rs.getString(book_usuario));
booking.setUserOffice(rs.getString(book_ofcn_usuario));
booking.setDocumentOrigin(rs.getString(book_origen_doc)); booking.setDocumentDestination(rs.getString(book_destino_doc));
booking.setFlightOrigin(rs.getString(book_origen_vuelo)); booking.setFlightDestination(rs.getString(book_destino_vuelo)); //booking.setCreationDate( getSimpleDate
(rs,book_fecha_gen).toDate() ); //booking.setFlightDate( getSimpleDate(rs,book_fecha_embarque).toDate() );
booking.setDocumentPrefix(new Long(rs.getLong(book_pref_doc )));
booking.setDocumentNumber(new Long(rs.getLong(book_num_doc )));
booking.setAgentCode(new Long(rs.getLong(book_clhl_cdg)));
booking.setAgentBranchCode(new Long(rs.getLong(book_clhl_scrs))); booking.setAgentContactName(rs.getString(book_contacto_agente)); booking.setAgentContactPhone

(rs.getString(book_fono_contacto)); booking.setShipperCode(new Long(rs.getLong(book_cdg_shipper)));
booking.setShipperBranchCode(new Long(rs.getLong(book_scrs_shipper)));
booking.setShipperName(rs.getString(book_nmb_shipper));
booking.setConsigneeCode(new Long(rs.getLong(book_cdg_consignee)));
booking.setConsigneeName(rs.getString(book_nmb_consignee));
booking.setConsigneeBranchCode(new Long(rs.getLong(book_scrs_consignee)));
booking.setAverageRate(new Double(rs.getDouble(book_tarifa)));
booking.setRemarks(rs.getString(book_remarks));
booking.setTotalWeight(new Double(rs.getDouble(book_gross)));
booking.setChargeableWeight(new Double(rs.getDouble(book_chargeable)));
booking.setTotalVolume(new Double(rs.getDouble(book_volumen_total))); booking.setTotalPieces(new Long(rs.getLong(book_total_piezas)));
booking.setAgentName(rs.getString(book_nmb_agente));
booking.setAgentAcronym(rs.getString(book_acronimo_agente)); booking.setShipperAcronym(rs.getString(book_acronimo_shipper)); booking.setConsigneeAcronym(rs.getString

(book_acronimo_consignee));

Re: Getting connection from ibatis

2005-10-06 Thread Larry Meadors
The simplest way is to use JNDI for your datasource / transaction manager.

Larry

On 10/6/05, Agilan Palani [EMAIL PROTECTED] wrote:



 Hi



 Iam using ibatis in my project, with JBoss application server.



 I have some taglibs from oracle which uploads ORDImages (Oracle specific
 objects) to the database

 ord:storeMedia 

 These tags either need  a connection or datasource, passed as one of its
 argument to perform its task.

 Those tags will take care of committing and closing the connections.



 Q1. How do I get the connection from IBATIS?

 Q2. How do I get the datasource from IBATIS?



 Any help will be very useful, thanks in advance.



 Regards

 Agilan Palani


Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

2005-10-06 Thread Sven.Boden

If it's on Oracle using inline parameters will be slower.

Regards,
Sven

- Oorspronkelijk bericht -
Van: Clinton Begin [mailto:[EMAIL PROTECTED]
Verzonden: donderdag, oktober 6, 2005 01:18 PM
Aan: user-java@ibatis.apache.org
Onderwerp: Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

PS: We cannot acknowledge performance test results, nor can we answer
questions or do anything about them -- unless you post your test code
including database scripts and platform details.

Cheers,
Clinton

On 10/6/05, Clinton Begin [EMAIL PROTECTED] wrote:


 If you are seriously worried about 220ms of time in an enterprise
 aplication, then iBATIS (and all other frameworks) are not for you. Stick
 with JDBC.

 Performance testing enterprise applications is very complex, and you
 should avoid drawing conclusions based on simple tests of 10 executions of a
 single SQL statement.

 Have you tested Struts compared to plain Servlets and JSP?

 Cheers,
 Clinton

 On 10/5/05, Rodrigo Castillo [EMAIL PROTECTED] wrote:
 
  Hi,
 
  I built two testing over framwork ibatis, I had used JdbcDaoTemplate and
  SqlMapDaoTemplate both implement the same query, the JDBC drivers is
  oracle.
 
 
  1) JdbcDaoTemplate
  the average of method execute() is 80ms (with 10 execution)
 
  2) SqlMapDaoTemplate
  the average of method execute() is 300ms (with 10 execution) class
  com.ibatis.sqlmap.engine.execution.SqlExecutor
 
  why the method execute() of SqlMapDaoTemplate is slower than Jdbc if it
  is
  using the same framework?
 
 
  --
  source JdbcDaoTemplate
  --
  public class TestingJDBCDAO extends JdbcDaoTemplate implements
  TestingPLDAO{
 
 
  public TestingJDBCDAO (DaoManager daoManager) {
  super(daoManager);
  }
 
  public List findBookingByFlightJDBC(FlightDBO flight) {
  Collection result = new ArrayList();
 
  try {
 
  Connection conn = getConnection();
 
  // Llamada a PL para buscar listado de vuelos.
  int index = 1;
  StringBuffer call = new StringBuffer();
 
  call.append (select * from book b, vlbk v );
  call.append( where b.prbk_seq_cdg = v.prbk_seq_cdg );
  call.append( and v.lnar_cdg_iata=?);
  call.append( and v.vlos_cdg=?);
  call.append( and v.vlos_fch=to_date(?,'dd/mm/') );
  call.append( and v.vlbk_origen=? );
  call.append( and v.vlbk_destino =? );
 
  // Crear statement y agregarlo a 'closer'.
  PreparedStatement cstmt = conn.prepareStatement(call.toString());
 
  // Se Asignan parámetros para el PL.
  cstmt.setString ( index++, flight.getIataCode()); // 1
  cstmt.setLong(index++, flight.getFlightNumber().longValue()); // 2
  SimpleDate fecha = new SimpleDate(flight.getFlightDate());
  cstmt.setString (index++, fecha.toString(dd/MM/) ); // 3
  cstmt.setString( index++, flight.getFlightOrigin()); // 4
  cstmt.setString( index++, flight.getFlightDestination()); // 5
 
  LapseMeter l= new LapseMeter();
  cstmt.execute(); // Ejecuta el PL.
  System.out.println(time execute +l.lapse());
 
  ResultSet rs = cstmt.getResultSet(); // Ejecuta el PL.
 
  // Obtiene cursor con los registros.
  BookingDBO booking = null;
 
  while ( rs.next()) {
 
  booking = new BookingDBO();
 
  booking.setBookingCode(new Long(rs.getLong(prbk_seq_cdg)));
  booking.setCompanyCode(new Long(rs.getLong(book_empr_cdg)));
  booking.setAirlineCode(rs.getString(lnar_cdg_iata));
  booking.setStatus(rs.getString(esbk_cdg_estd));
  booking.setBookingType(rs.getString(tpbk_cdg_booking));
  booking.setDocumentType(rs.getString(tdoc_cdg));
  booking.setUser(rs.getString(book_usuario));
  booking.setUserOffice(rs.getString(book_ofcn_usuario));
  booking.setDocumentOrigin(rs.getString(book_origen_doc));
  booking.setDocumentDestination(rs.getString
  (book_destino_doc));
  booking.setFlightOrigin(rs.getString(book_origen_vuelo));
  booking.setFlightDestination(rs.getString
  (book_destino_vuelo));
  //booking.setCreationDate( getSimpleDate
  (rs,book_fecha_gen).toDate() );
  //booking.setFlightDate( getSimpleDate
  (rs,book_fecha_embarque).toDate() );
  booking.setDocumentPrefix(new Long(rs.getLong
  (book_pref_doc )));
  booking.setDocumentNumber(new Long(rs.getLong
  (book_num_doc )));
  booking.setAgentCode(new Long(rs.getLong(book_clhl_cdg)));
  booking.setAgentBranchCode(new Long(rs.getLong
  (book_clhl_scrs)));
  booking.setAgentContactName(rs.getString
  (book_contacto_agente));
  booking.setAgentContactPhone (rs.getString
  (book_fono_contacto));
  booking.setShipperCode(new Long(rs.getLong
  (book_cdg_shipper)));
  booking.setShipperBranchCode(new Long(rs.getLong
  (book_scrs_shipper)));
  booking.setShipperName(rs.getString(book_nmb_shipper));
  booking.setConsigneeCode(new Long(rs.getLong
  (book_cdg_consignee)));
  booking.setConsigneeName(rs.getString(book_nmb_consignee));
  booking.setConsigneeBranchCode(new Long(rs.getLong
  (book_scrs_consignee)));
  booking.setAverageRate(new 

RE: Getting connection from ibatis

2005-10-06 Thread Agilan Palani
Iam already using a datasource for IBATIS, do you mean I need to lookup that
datasource again by-passing IBATIS and pass it to the taglib?


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Larry Meadors
Sent: Thursday, October 06, 2005 8:12 PM
To: user-java@ibatis.apache.org
Subject: Re: Getting connection from ibatis

The simplest way is to use JNDI for your datasource / transaction manager.

Larry

On 10/6/05, Agilan Palani [EMAIL PROTECTED] wrote:



 Hi



 Iam using ibatis in my project, with JBoss application server.



 I have some taglibs from oracle which uploads ORDImages (Oracle specific
 objects) to the database

 ord:storeMedia 

 These tags either need  a connection or datasource, passed as one of its
 argument to perform its task.

 Those tags will take care of committing and closing the connections.



 Q1. How do I get the connection from IBATIS?

 Q2. How do I get the datasource from IBATIS?



 Any help will be very useful, thanks in advance.



 Regards

 Agilan Palani



Re: Getting connection from ibatis

2005-10-06 Thread Larry Meadors
That is what I would do, yes.

Larry


On 10/6/05, Agilan Palani [EMAIL PROTECTED] wrote:
 Iam already using a datasource for IBATIS, do you mean I need to lookup that
 datasource again by-passing IBATIS and pass it to the taglib?


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
 Larry Meadors
 Sent: Thursday, October 06, 2005 8:12 PM
 To: user-java@ibatis.apache.org
 Subject: Re: Getting connection from ibatis

 The simplest way is to use JNDI for your datasource / transaction manager.

 Larry

 On 10/6/05, Agilan Palani [EMAIL PROTECTED] wrote:
 
 
 
  Hi
 
 
 
  Iam using ibatis in my project, with JBoss application server.
 
 
 
  I have some taglibs from oracle which uploads ORDImages (Oracle specific
  objects) to the database
 
  ord:storeMedia 
 
  These tags either need  a connection or datasource, passed as one of its
  argument to perform its task.
 
  Those tags will take care of committing and closing the connections.
 
 
 
  Q1. How do I get the connection from IBATIS?
 
  Q2. How do I get the datasource from IBATIS?
 
 
 
  Any help will be very useful, thanks in advance.
 
 
 
  Regards
 
  Agilan Palani




Changing a sqlMap dynamically?

2005-10-06 Thread Dan Bradley
Using iBATIS you normally create an XML file with a sqlMap element
that defines SQL queries that can be referenced by name. Is it also
possible to create these queries dynamically, through Java, instead of
hard-coding them all in XML? I'm hoping to build some framework code
that will programatically create some common queries based on the
properties of an object, instead of writing a getAll or getById
query for every entity which varies only in the table name.

SqlMapExecutor's query/insert/delete methods require the name of a
mapped statement and don't appear to allow arbitrary SQL. If iBATIS
supports what I'm looking for, where would you hook into the system in
order to create new mappings on the fly?

Thanks.


Re: Changing a sqlMap dynamically?

2005-10-06 Thread Larry Meadors
select id=getWhatever resultClass=java.util.HashMap remapResults=true
$whateverSqlYouWant$
/select

Larry


On 10/6/05, Dan Bradley [EMAIL PROTECTED] wrote:
 Using iBATIS you normally create an XML file with a sqlMap element
 that defines SQL queries that can be referenced by name. Is it also
 possible to create these queries dynamically, through Java, instead of
 hard-coding them all in XML? I'm hoping to build some framework code
 that will programatically create some common queries based on the
 properties of an object, instead of writing a getAll or getById
 query for every entity which varies only in the table name.

 SqlMapExecutor's query/insert/delete methods require the name of a
 mapped statement and don't appear to allow arbitrary SQL. If iBATIS
 supports what I'm looking for, where would you hook into the system in
 order to create new mappings on the fly?

 Thanks.



RE: Getting connection from ibatis

2005-10-06 Thread Agilan Palani

Thanks, but, do you have any answer to get the connection directly? Another
project is running on a web-server which doesn't have a datasource, but uses
IBATIS



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Larry Meadors
Sent: Thursday, October 06, 2005 10:04 PM
To: user-java@ibatis.apache.org
Subject: Re: Getting connection from ibatis

That is what I would do, yes.

Larry


On 10/6/05, Agilan Palani [EMAIL PROTECTED] wrote:
 Iam already using a datasource for IBATIS, do you mean I need to lookup
that
 datasource again by-passing IBATIS and pass it to the taglib?


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of
 Larry Meadors
 Sent: Thursday, October 06, 2005 8:12 PM
 To: user-java@ibatis.apache.org
 Subject: Re: Getting connection from ibatis

 The simplest way is to use JNDI for your datasource / transaction manager.

 Larry

 On 10/6/05, Agilan Palani [EMAIL PROTECTED] wrote:
 
 
 
  Hi
 
 
 
  Iam using ibatis in my project, with JBoss application server.
 
 
 
  I have some taglibs from oracle which uploads ORDImages (Oracle specific
  objects) to the database
 
  ord:storeMedia 
 
  These tags either need  a connection or datasource, passed as one of its
  argument to perform its task.
 
  Those tags will take care of committing and closing the connections.
 
 
 
  Q1. How do I get the connection from IBATIS?
 
  Q2. How do I get the datasource from IBATIS?
 
 
 
  Any help will be very useful, thanks in advance.
 
 
 
  Regards
 
  Agilan Palani





Re: iBATIS strange behaviour

2005-10-06 Thread Larry Meadors
Hmm, this seems really odd. The code that is in SVN now supports
properties named like sProperty with mutators like getsProperty
and setsProperty.

According to the beans specification, getters named getSProperty and
setSProperty define a property named SProperty, not sProperty as
you might expect. (BTW, the iBATIS in SVN does that, too).

OK, I answered the first two questions...someone else gets the last one. ;-)

Two questions for you:
 - How are your getter/setter methods named?
 - What version of iBATIS are you using?

Larry


On 10/6/05, Pere Torrodellas [EMAIL PROTECTED] wrote:
 I ran into this strange problem that required a lot of time to debug. This
 is just to try to save trouble for those that run into it.

 iBATIS version: 2.1.5

 This first data map works OK:

 typeAlias alias=Oferta type=gov.soc.web.model.ofertes.Oferta/
 select id=getOferta parameterClass=java.lang.Integer
 resultClass=Oferta
 select
 ID_OFERTA as iIdOferta,
 OCUPACIO as stOcupacio,
 MUNICIPIO as stLocalitat
 from OFERTAS
 where ID_OFERTA = #value#
 /select

 But this one throws an exception:

 typeAlias alias=Oferta type=gov.soc.web.model.ofertes.Oferta/
 resultMap id=getOfertaResult class=Oferta
 result property=iIdOferta column=ID_OFERTA/
 result property=stOcupacio column=OCUPACIO/
 result property=stLocalitat column=MUNICIPIO/
 /resultMap
 select id=getOferta parameterClass=java.lang.Integer
 resultMap=getOfertaResult
select
ID_OFERTA,
OCUPACIO,
MUNICIPIO
from OFERTAS
where ID_OFERTA = #value#
 /select

 Note that result class, property names and table are the same in both cases.

 The exception says:

 com.ibatis.common.beans.ProbeException: There is no WRITEABLE property named
 'iIdOferta' in class 'gov.soc.web.model.ofertes.Oferta'

 ...which is wrong because I checked umpteen times property name and setter
 method, and what's more: it works with the first data map format.

 Commenting out the result tag for the iIdOferta property, the second data
 map format also works OK.

 After many, many tests and Mail Archive searches, I tried in despair a last
 one: I changed the property name from iIdOferta to inIdOferta, together with
 its getter/setter... IT WORKED!!!

 So... is this an iBATIS bug? Doesn't it like property names that start with
 a lowercase letter followed by an uppercase letter? If so, why does it work
 with the first data map format? Can someone offer an explanation?

 Just be warned.

 Regards,

 Pere






Re: Changing a sqlMap dynamically?

2005-10-06 Thread Dan Bradley
Hi Larry -

Thanks for the reply, but I think you misunderstood the question. I
understand that I can put arbitrary SQL into a named select element
within a sqlMap file. That then gets called, by name, from
SqlMapExecutor/Session.

What I'm wondering is if there's either:

- a way to (essentially) call session.select(my arbitrary sql)
instead of session.select(namedQuery)
- or to created new named mappings at runtime such that
select(namedQuery) is calling a query that doesn't exist in the XML
file on disk.

My goal is, if I have 10 entities, and they all have a query that
looks like select * from tablename and the only that that varies is
the tablename, I'd like to be able to have my Java create that query
on the fly. I'm looking to build a general framework that handles some
of the plumbing for me instead of requiring a lot of hand work to be
done building the XML files.

Thanks.

On 10/6/05, Larry Meadors [EMAIL PROTECTED] wrote:
 select id=getWhatever resultClass=java.util.HashMap remapResults=true
 $whateverSqlYouWant$
 /select

 Larry


 On 10/6/05, Dan Bradley [EMAIL PROTECTED] wrote:
  Using iBATIS you normally create an XML file with a sqlMap element
  that defines SQL queries that can be referenced by name. Is it also
  possible to create these queries dynamically, through Java, instead of
  hard-coding them all in XML? I'm hoping to build some framework code
  that will programatically create some common queries based on the
  properties of an object, instead of writing a getAll or getById
  query for every entity which varies only in the table name.
 
  SqlMapExecutor's query/insert/delete methods require the name of a
  mapped statement and don't appear to allow arbitrary SQL. If iBATIS
  supports what I'm looking for, where would you hook into the system in
  order to create new mappings on the fly?
 
  Thanks.
 



Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

2005-10-06 Thread Jan Vissers

Hi Sven,

Like to hear from you, how you came to that conclusion.

-J

Sven.Boden wrote:


If it's on Oracle using inline parameters will be slower.

Regards,
Sven

 


- Oorspronkelijk bericht -
Van: Clinton Begin [mailto:[EMAIL PROTECTED]
Verzonden: donderdag, oktober 6, 2005 01:18 PM
Aan: user-java@ibatis.apache.org
Onderwerp: Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

PS: We cannot acknowledge performance test results, nor can we answer
questions or do anything about them -- unless you post your test code
including database scripts and platform details.

Cheers,
Clinton

On 10/6/05, Clinton Begin [EMAIL PROTECTED] wrote:
   


If you are seriously worried about 220ms of time in an enterprise
aplication, then iBATIS (and all other frameworks) are not for you. Stick
with JDBC.

Performance testing enterprise applications is very complex, and you
should avoid drawing conclusions based on simple tests of 10 executions of a
single SQL statement.

Have you tested Struts compared to plain Servlets and JSP?

Cheers,
Clinton

On 10/5/05, Rodrigo Castillo [EMAIL PROTECTED] wrote:
 


Hi,

I built two testing over framwork ibatis, I had used JdbcDaoTemplate and
SqlMapDaoTemplate both implement the same query, the JDBC drivers is
oracle.


1) JdbcDaoTemplate
the average of method execute() is 80ms (with 10 execution)

2) SqlMapDaoTemplate
the average of method execute() is 300ms (with 10 execution) class
com.ibatis.sqlmap.engine.execution.SqlExecutor

why the method execute() of SqlMapDaoTemplate is slower than Jdbc if it
is
using the same framework?


--
source JdbcDaoTemplate
--
public class TestingJDBCDAO extends JdbcDaoTemplate implements
TestingPLDAO{


public TestingJDBCDAO (DaoManager daoManager) {
super(daoManager);
}

public List findBookingByFlightJDBC(FlightDBO flight) {
Collection result = new ArrayList();

try {

Connection conn = getConnection();

// Llamada a PL para buscar listado de vuelos.
int index = 1;
StringBuffer call = new StringBuffer();

call.append (select * from book b, vlbk v );
call.append( where b.prbk_seq_cdg = v.prbk_seq_cdg );
call.append( and v.lnar_cdg_iata=?);
call.append( and v.vlos_cdg=?);
call.append( and v.vlos_fch=to_date(?,'dd/mm/') );
call.append( and v.vlbk_origen=? );
call.append( and v.vlbk_destino =? );

// Crear statement y agregarlo a 'closer'.
PreparedStatement cstmt = conn.prepareStatement(call.toString());

// Se Asignan parámetros para el PL.
cstmt.setString ( index++, flight.getIataCode()); // 1
cstmt.setLong(index++, flight.getFlightNumber().longValue()); // 2
SimpleDate fecha = new SimpleDate(flight.getFlightDate());
cstmt.setString (index++, fecha.toString(dd/MM/) ); // 3
cstmt.setString( index++, flight.getFlightOrigin()); // 4
cstmt.setString( index++, flight.getFlightDestination()); // 5

LapseMeter l= new LapseMeter();
cstmt.execute(); // Ejecuta el PL.
System.out.println(time execute +l.lapse());

ResultSet rs = cstmt.getResultSet(); // Ejecuta el PL.

// Obtiene cursor con los registros.
BookingDBO booking = null;

while ( rs.next()) {

booking = new BookingDBO();

booking.setBookingCode(new Long(rs.getLong(prbk_seq_cdg)));
booking.setCompanyCode(new Long(rs.getLong(book_empr_cdg)));
booking.setAirlineCode(rs.getString(lnar_cdg_iata));
booking.setStatus(rs.getString(esbk_cdg_estd));
booking.setBookingType(rs.getString(tpbk_cdg_booking));
booking.setDocumentType(rs.getString(tdoc_cdg));
booking.setUser(rs.getString(book_usuario));
booking.setUserOffice(rs.getString(book_ofcn_usuario));
booking.setDocumentOrigin(rs.getString(book_origen_doc));
booking.setDocumentDestination(rs.getString
(book_destino_doc));
booking.setFlightOrigin(rs.getString(book_origen_vuelo));
booking.setFlightDestination(rs.getString
(book_destino_vuelo));
//booking.setCreationDate( getSimpleDate
(rs,book_fecha_gen).toDate() );
//booking.setFlightDate( getSimpleDate
(rs,book_fecha_embarque).toDate() );
booking.setDocumentPrefix(new Long(rs.getLong
(book_pref_doc )));
booking.setDocumentNumber(new Long(rs.getLong
(book_num_doc )));
booking.setAgentCode(new Long(rs.getLong(book_clhl_cdg)));
booking.setAgentBranchCode(new Long(rs.getLong
(book_clhl_scrs)));
booking.setAgentContactName(rs.getString
(book_contacto_agente));
booking.setAgentContactPhone (rs.getString
(book_fono_contacto));
booking.setShipperCode(new Long(rs.getLong
(book_cdg_shipper)));
booking.setShipperBranchCode(new Long(rs.getLong
(book_scrs_shipper)));
booking.setShipperName(rs.getString(book_nmb_shipper));
booking.setConsigneeCode(new Long(rs.getLong
(book_cdg_consignee)));
booking.setConsigneeName(rs.getString(book_nmb_consignee));
booking.setConsigneeBranchCode(new Long(rs.getLong
(book_scrs_consignee)));
booking.setAverageRate(new Double(rs.getDouble(book_tarifa)));
booking.setRemarks(rs.getString(book_remarks));
booking.setTotalWeight(new 

Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

2005-10-06 Thread Jan Vissers
Thanks for sharing, I was always under the impression that inline 
parameters didn't mean hard parses. I'm quite aware of the fact that 
this might hurt Oracle.


Checking...

Sven Boden wrote:


Simple... the SQL code executed by the JDBC example and the iBATIS
version is not the same. The JDBC examples use parameter markers and
proper arguments, while the iBATIS version in the original mail uses
inline parameters, the #value# (which means that the SQL generated
will contain hardcoded parameters)... By the way iBATIS can also use
parameters markers.

Oracle performance suffers very badly when using hardcoded arguments.
I could make my own example but have a look e.g. at Tom Kyte's site
http://asktom.oracle.com and search for hard parsing... you will get
a complete explanation why hardcoding is bad.

Personally I've seen in Oracle examples of executing SQL in a loop
with different arguments where with proper parameters the code would
take 2 seconds, and with harcoded arguments the same SQL took 2
minutes.

So if the database is Oracle a more proper comparison would be to
hardcode the arguments in the JDBC example, or use parameter markers
in iBATIS.

Regards,
Sven


On Thu, 06 Oct 2005 23:45:41 +0200, you wrote:

 


Hi Sven,

Like to hear from you, how you came to that conclusion.

-J

   





 



--
Cumquat Information Technology
De Dreef 19
3706 BR Zeist
T +31 (0)30 - 6940490
F +31 (0)10 - 6940499
http://www.cumquat.nl

[EMAIL PROTECTED]
M +31 6 51 169 556




Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

2005-10-06 Thread Sven Boden

I may be mixing up things... let me check as well ;-) $/#/...

Sven

On Fri, 07 Oct 2005 00:20:47 +0200, you wrote:

Thanks for sharing, I was always under the impression that inline 
parameters didn't mean hard parses. I'm quite aware of the fact that 
this might hurt Oracle.

Checking...

Sven Boden wrote:



Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

2005-10-06 Thread Jan Vissers

Point of interest is InlineParameterMapParser.

   mappingList.add(mapping);
   newSqlBuffer.append(?);
   ...
   ...
   newSql = newSqlBuffer.toString();
   ParameterMapping[] mappingArray = (ParameterMapping[])
   mappingList.toArray(new ParameterMapping[mappingList.size()]);

   SqlText sqlText = new SqlText();
   sqlText.setText(newSql);
   sqlText.setParameterMappings(mappingArray);

Looks ok to me.


Sven Boden wrote:


I may be mixing up things... let me check as well ;-) $/#/...

Sven

On Fri, 07 Oct 2005 00:20:47 +0200, you wrote:

 

Thanks for sharing, I was always under the impression that inline 
parameters didn't mean hard parses. I'm quite aware of the fact that 
this might hurt Oracle.


Checking...

Sven Boden wrote:
   





 



--
Cumquat Information Technology
De Dreef 19
3706 BR Zeist
T +31 (0)30 - 6940490
F +31 (0)10 - 6940499
http://www.cumquat.nl

[EMAIL PROTECTED]
M +31 6 51 169 556




Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

2005-10-06 Thread Sven Boden

I may be mixing up things... let me check as well ;-)
Sven

On Fri, 07 Oct 2005 00:20:47 +0200, you wrote:

Thanks for sharing, I was always under the impression that inline 
parameters didn't mean hard parses. I'm quite aware of the fact that 
this might hurt Oracle.

Checking...

Sven Boden wrote:



Re: why does SqlMap ibatis is slower that JdbcDaoTemplate

2005-10-06 Thread Jan Vissers

I also checked with the single point of truth - the database.
For those interested...

Mapping:
 select id=getRegisteredAction resultClass=registeredAction
   SELECT REAC_ID as id
   ,  REAC_NAME as name
   ,  REAC_DESCRIPTION as description
   ,  REAC_IND_ACTIVE as active
   FROM   CXF_REGISTERED_ACTIONS
   WHERE  REAC_ID = #value#
 /select

Mini tester:

public static void main(String[] args) throws SQLException {
  SqlMapClient sqlMap = SqlMapConfig.getSqlMapInstance();
  PreparedStatement stmt = sqlMap.getCurrentConnection().
prepareStatement(alter system set sql_trace=true);
  stmt.execute();

  sqlMap.queryForObject (getRegisteredAction, new Long(1)); 
  sqlMap.queryForObject (getRegisteredAction, new Long(2));

}

Execute the above on a freshly started database instance.

Interpretation of Oracle trace file:

1st occurrence:

PARSING IN CURSOR #3 len=190 dep=0 uid=57 oct=3 lid=57 tim=2640378680 
hv=2472912027 ad='69e65bc8'
SELECT REAC_ID as id ,  REAC_NAME as name ,  
REAC_DESCRIPTION as description ,  REAC_IND_ACTIVE as active 
FROM   CXF_REGISTERED_ACTIONS WHERE  REAC_ID = *:1*  
END OF STMT

PARSE #3:c=0,*e=353*,p=0,cr=0,cu=0,*mis=1*,r=0,dep=0,og=1,tim=2640378675

2nd occurrence:

PARSING IN CURSOR #4 len=190 dep=0 uid=57 oct=3 lid=57 tim=2640557676 
hv=2472912027 ad='69e65bc8'
SELECT REAC_ID as id ,  REAC_NAME as name ,  
REAC_DESCRIPTION as description ,  REAC_IND_ACTIVE as active 
FROM   CXF_REGISTERED_ACTIONS WHERE  REAC_ID = :1  
END OF STMT

PARSE #4:c=0,*e=59*,p=0,cr=0,cu=0,*mis=0*,r=0,dep=0,og=1,tim=2640557673

Notice that:

  1. Bind variables are actually used   *:1*
  2. 1st occurence is an Oracle hard parse indicated by a library cache
 mis  *mis=1*
  3. 2nd occurence is an Oracle soft parse indicated by a library cache
 hit  *mis=0*
  4. Hard parses are (obviously) more expensive than soft, *353 vs. 59*

-J.

Sven Boden wrote:


Sorry for that... the difference between # and $... # results in
parameter markers. It's getting too late for me (for the developers...
at
com.ibatis.sqlmap.engine.mapping.parameter.InlineParameterMapParser)

Back to the thinking board.

Regards,
Sven





 



--
Cumquat Information Technology
De Dreef 19
3706 BR Zeist
T +31 (0)30 - 6940490
F +31 (0)10 - 6940499
http://www.cumquat.nl

[EMAIL PROTECTED]
M +31 6 51 169 556




Re: Sybase selectKey problem

2005-10-06 Thread reubenf
BTW, this *does* work:

insert id=createDeployment parameterClass=deployment
selectKey resultClass=int keyProperty=deploymentId
SELECT MAX(deploymentId) + 1 FROM Deployment
/selectKey

INSERT INTO Deployment (deploymentId, environmentId,
deploymentTypeId, userName, deploymentStatusId, deploymentTime,
threadCountOverride)
VALUES (#deploymentId#, #environmentId#, #deploymentTypeId#,
#userName#,
#deploymentStatusId#, #deploymentTime#,
#threadCountOverride#)
/insert

BUT it directly contradicts the thread here:
http://www.mail-archive.com/user-java@ibatis.apache.org/msg00044.html

...in which the consensus that the selectKey operation for sybase is
identical to MSSQL in a) being after the insert and b) using @@IDENTITY.
Also it would seem to be counter to the examples in the docs, which don't
require that deploymentId be explicity passed to the insert.

What am I missing? Are these differences due to which JDBC driver I'm
using? (Jconn3)

#2 (below) still stands.

Thanks



 #2 -- Given that the insert/update statements are very much alike, is
 there a clean way to share the SQL between the two?




RE: Getting connection from ibatis

2005-10-06 Thread Agilan Palani


I hope that iam not clear in stating why I need a direct connection from
IBATIS, will correctly state is now.

My project runs in JBoss in one location and in tomcat in other places.
Code base is same. There are some java EOD programs which will also run as
separate process using IBATIS.

Tomcat is not configured with a datasource but JBoss is.
Hence I managed to define two context tags in the ibatis config file, and
I will choose the context dynamically based on the server in which the
project runs.
The first context will use datasource and the other will use simple jdbc
connection pool.

Some of our code were using oracle tag libraries and some servlets to get
oracle images and streaming media from the database. These tag libraries
expect a connection to be passed to it.

Hence I need to get the connection from IBATIS, where IBATIS will inturn get
the connection from the configured DataSource or the connection pool,
whatever it is configured to.

I had done some home work to get the connection from IBATIS, but not sure
whether iam doing it right. The following works when I use a SIMPLE JDBC
connection pool configuration, but doesn't work when I use the datasource.

Properties pCnf = new Properties();

-- 
if( direct.equals(dbCtx) ){
 pCnf.put(ibatis.mapping.config,conf/sql-map-config.xml);
}else{
pCnf.put(ibatis.mapping.config,conf/sql-map-config-ds.xml);
}
daoManager = DaoManagerBuilder.buildDaoManager(reader,pCnf);
csafeDAO = (CsafeDAO) getDaoManager().getDao(CsafeDAO.class);

--

  public Connection getConnection(){
return ( (ConnectionDaoTransaction) 
daoManager.getTransaction(csafeDAO) ).getConnection();
}

--

conn = getConnection();
stm = conn.createStatement();
rs = stm.executeQuery(query);
// Fetch the underlying resultset from the JBoss Wrap
//if the connection is from datasource
if (rs instanceof org.jboss.resource.adapter.jdbc.WrappedResultSet ) {
rs = ((org.jboss.resource.adapter.jdbc.WrappedResultSet)
rs).getUnderlyingResultSet();
}

// then cast to the OracleResultSet 
OracleResultSet oraRs = (OracleResultSet) rs;

if(oraRs.next()){
image = (OrdImage)
oraRs.getORAData(image,OrdImage.getORADataFactory());  
}

-

If I use simple JDBC it works, but when datasource is used it throws the
ClassCastException when I cast the resultset to OracleResultSet, any inputs?


06-Oct PM 5:54:02 ERROR [bl.ORDImageBO].getImageFromDB() Connection to DB
failed: java.lang.ClassCastException: $Proxy64
java.lang.ClassCastException: $Proxy64
at
com.bntasia.vivo.app.bl.ORDImageBO.getImageFromDB(ORDImageBO.java:254)
at
com.bntasia.vivo.app.bl.ORDImageBO.getImageFromDB(ORDImageBO.java:181)
at
com.bntasia.vivo.app.bl.ORDImageBO.getAssetTypeImageFromDB(ORDImageBO.java:1
18)



-Original Message-
From: Agilan Palani [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 06, 2005 10:16 PM
To: user-java@ibatis.apache.org; [EMAIL PROTECTED]
Subject: RE: Getting connection from ibatis
Importance: High


Thanks, but, do you have any answer to get the connection directly? Another
project is running on a web-server which doesn't have a datasource, but uses
IBATIS



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Larry Meadors
Sent: Thursday, October 06, 2005 10:04 PM
To: user-java@ibatis.apache.org
Subject: Re: Getting connection from ibatis

That is what I would do, yes.

Larry


On 10/6/05, Agilan Palani [EMAIL PROTECTED] wrote:
 Iam already using a datasource for IBATIS, do you mean I need to lookup
that
 datasource again by-passing IBATIS and pass it to the taglib?


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of
 Larry Meadors
 Sent: Thursday, October 06, 2005 8:12 PM
 To: user-java@ibatis.apache.org
 Subject: Re: Getting connection from ibatis

 The simplest way is to use JNDI for your datasource / transaction manager.

 Larry

 On 10/6/05, Agilan Palani [EMAIL PROTECTED] wrote:
 
 
 
  Hi
 
 
 
  Iam using ibatis in my project, with JBoss application server.
 
 
 
  I have some taglibs from oracle which uploads ORDImages (Oracle specific
  objects) to the database
 
  ord:storeMedia 
 
  These tags either need  a connection or datasource, passed as one of its
  argument to perform its task.
 
  Those tags will take care of committing and closing the connections.
 
 
 
  Q1. How do I get the connection from IBATIS?
 
  Q2. How do I get the datasource from IBATIS?
 
 
 
  Any help will be very useful, thanks in advance.
 
 
 
  Regards
 
  Agilan Palani





Re: Sybase selectKey problem

2005-10-06 Thread Zarar Siddiqi
Try this as the selectKey query.  I think you have to select the column as 
value.   I'm assuming your deployment class has a deploymentId 
property.


selectKey resultClass=int keyProperty=deploymentId
   SELECT @@IDENTITY AS value
/selectKey

Zarar


- Original Message - 
From: [EMAIL PROTECTED]

To: user-java@ibatis.apache.org
Sent: Thursday, October 06, 2005 9:00 PM
Subject: Sybase selectKey problem



#1 -- I'm trying to use selectKey to create keys for me. DB is Sybase.

My insert is as follows:

   insert id=createDeployment parameterClass=deployment
   INSERT INTO Deployment (environmentId, deploymentTypeId, userName,
deploymentStatusId, deploymentTime, threadCountOverride)
   VALUES (#environmentId#, #deploymentTypeId#, #userName#,
#deploymentStatusId#, #deploymentTime#,
#threadCountOverride#)   selectKey resultClass=int
keyProperty=deploymentId
   SELECT @@IDENTITY AS deploymentId
   /selectKey
   /insert

(BTW the dev guide does not mention keyProperty -- I found that in this
thread:
http://www.mail-archive.com/user-java@ibatis.apache.org/msg00044.html)


I get the following error:

Caused by: com.sybase.jdbc3.jdbc.SybSQLException: The column deploymentId
in table Deployment does not allow null values.

at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:442)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:81)
at
org.springframework.orm.ibatis.SqlMapClientTemplate$9.doInSqlMapClient(SqlMapClientTemplate.java:319)
at
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:181)
at
org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:317)


#2 -- Given that the insert/update statements are very much alike, is
there a clean way to share the SQL between the two?

Thanks
Reuben





Re: Sybase selectKey problem

2005-10-06 Thread Larry Meadors
Hmm, what happens when you do the insert from a plain-jane sql client?

In this case, the exception is coming *BEFORE* the selectKey element
gets executed:

 Caused by: com.sybase.jdbc3.jdbc.SybSQLException: The column deploymentId
 in table Deployment does not allow null values.

The column does not allow null values...that tells us that the
generated key is not getting generated. :-)

This should work:

insert id=createDeployment parameterClass=deployment
INSERT INTO Deployment (
environmentId, deploymentTypeId,
userName, deploymentStatusId,
deploymentTime,  threadCountOverride
) VALUES (
#environmentId#, #deploymentTypeId#,
#userName#, #deploymentStatusId#,
#deploymentTime#, #threadCountOverride#)
selectKey resultClass=int keyProperty=deploymentId
SELECT @@IDENTITY as value
/selectKey
/insert

Someone else suggested SELECT MAX(deploymentId)+1..., which is a
really bad idea. Threading and concurrency will kill you doing that.
Just say no.

I know with M$SQL, select scope_identity() is the prefered way to
get generated keys (because of potential trigger issues), and I am not
sure if that is an option on sybase..if it is, you may want to look at
that.

Larry


On 10/6/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 #1 -- I'm trying to use selectKey to create keys for me. DB is Sybase.

 My insert is as follows:

 insert id=createDeployment parameterClass=deployment
 INSERT INTO Deployment (environmentId, deploymentTypeId, userName,
 deploymentStatusId, deploymentTime, threadCountOverride)
 VALUES (#environmentId#, #deploymentTypeId#, #userName#,
  #deploymentStatusId#, #deploymentTime#,
 #threadCountOverride#)   selectKey resultClass=int
 keyProperty=deploymentId
 SELECT @@IDENTITY AS deploymentId
 /selectKey
 /insert

 (BTW the dev guide does not mention keyProperty -- I found that in this
 thread:
 http://www.mail-archive.com/user-java@ibatis.apache.org/msg00044.html)


 I get the following error:

 Caused by: com.sybase.jdbc3.jdbc.SybSQLException: The column deploymentId
 in table Deployment does not allow null values.

 at
 com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
 at
 com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:442)
 at
 com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:81)
 at
 org.springframework.orm.ibatis.SqlMapClientTemplate$9.doInSqlMapClient(SqlMapClientTemplate.java:319)
 at
 org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:181)
 at
 org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:317)


 #2 -- Given that the insert/update statements are very much alike, is
 there a clean way to share the SQL between the two?

 Thanks
 Reuben