You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ole Wendland <Ol...@gmx.de> on 2007/02/20 18:17:57 UTC

[Configuration] problems with changing the delimiter

Hello Guys,
please tell me whats the problem with this delimiter.
The Program is this one:

import org.apache.commons.configuration.*;
import java.io.*;
import java.util.List;
 
class SaveProperties
{    
  public static void main( String[] args )
  {

      try {    
        PropertiesConfiguration config = new 
PropertiesConfiguration("test.txt");
         config.setListDelimiter('|');
        
System.out.println(System.out.println(config.getList("test").get(0));

    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
  }
}

and the test.txt looks like this
test = one|two|three

The output I expect should be "one" but he can't split the List and 
gives me  "one|two|three". When I use a comma as Delimiter is everything 
fine.
What is my mistake?

Greetings Ole

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


RE: Update problems with hibernate & struts

Posted by Guoxue Zhang <zg...@yahoo.com>.
   
   
  public void update(Models persistentInstance) {
  log.debug("deleting Tt instance");
  try {
  getSession().update(persistentInstance);
  
  Transaction tx = getSession().beginTransaction();
  tx.commit();
  
  System.out.println(" tx.commit update successful In model");
  log.debug("delete successful");
  } catch (RuntimeException re) {
  log.error("delete failed", re);
  throw re;
  }
  }
  


Abbas Adel <bi...@tantawi.net> wrote:  Can you provide us with modeldao.update(); code 

-----Original Message-----
From: Guoxue Zhang [mailto:zguoxue@yahoo.com] 
Sent: Sunday, February 25, 2007 8:20 PM
To: Jakarta Commons Users List
Subject: Update problems with hibernate & struts

Hello Guys,

When I update a record using Hibernate and Struts, I have to transfer
primary key(type is LONG) to ModelUpdadteAction class from update.jsp file.


In ModelUpdateAction.java file: 

String v_id = request.getParameter("modelid");
Long v_idLong = Long.valueOf( v_id);

Models model = new Models();
model.setModelId(v_idLong);
model.setModelname("Update New record IN Models");

ModelsDAO modeldao = new ModelsDAO();
modeldao.update(model);

I cann't update the record. A error is: javax.servlet.ServletException: a
different object with the same identifier value was already associated with
the session:

If I directly update with a primary key: 

Long v_idLong = Long.valueOf( "55");

Models model = new Models();
model.setModelId(v_idLong);
model.setModelname("Update New record IN Models");

ModelsDAO modeldao = new ModelsDAO();
modeldao.update(model);

It is successful.

Please reply that is what is problem and how to solv it. Thank you.

Frank










---------------------------------
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.


__________ NOD32 2080 (20070225) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com


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



 
---------------------------------
The fish are biting.
 Get more visitors on your site using Yahoo! Search Marketing.

RE: Update problems with hibernate & struts

Posted by Abbas Adel <bi...@tantawi.net>.
Can you provide us with modeldao.update(); code 

-----Original Message-----
From: Guoxue Zhang [mailto:zguoxue@yahoo.com] 
Sent: Sunday, February 25, 2007 8:20 PM
To: Jakarta Commons Users List
Subject: Update problems with hibernate & struts

Hello Guys,
   
  When I update a record using Hibernate and Struts, I have to transfer
primary key(type is LONG) to ModelUpdadteAction class  from update.jsp file.

   
  In ModelUpdateAction.java file: 
   
  String v_id = request.getParameter("modelid");
  Long v_idLong = Long.valueOf( v_id);
  
  Models model = new Models();
  model.setModelId(v_idLong);
  model.setModelname("Update New record IN Models");
   
  ModelsDAO modeldao = new ModelsDAO();
  modeldao.update(model);
   
  I cann't update the record.  A error is: javax.servlet.ServletException: a
different object with the same identifier value was already associated with
the session:
   
  If I directly update with a primary key: 
   
  Long v_idLong = Long.valueOf( "55");
  
  Models model = new Models();
  model.setModelId(v_idLong);
  model.setModelname("Update New record IN Models");
   
  ModelsDAO modeldao = new ModelsDAO();
  modeldao.update(model);
   
  It is successful.
   
  Please reply that is what is problem and how to solv it. Thank you.
   
  Frank
   
   
   
   
  
  
 
   

 
---------------------------------
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.


__________ NOD32 2080 (20070225) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com


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


Update problems with hibernate & struts

Posted by Guoxue Zhang <zg...@yahoo.com>.
Hello Guys,
   
  When I update a record using Hibernate and Struts, I have to transfer primary key(type is LONG) to ModelUpdadteAction class  from update.jsp file. 
   
  In ModelUpdateAction.java file: 
   
  String v_id = request.getParameter("modelid");
  Long v_idLong = Long.valueOf( v_id);
  
  Models model = new Models();
  model.setModelId(v_idLong);
  model.setModelname("Update New record IN Models");
   
  ModelsDAO modeldao = new ModelsDAO();
  modeldao.update(model);
   
  I cann't update the record.  A error is: javax.servlet.ServletException: a different object with the same identifier value was already associated with the session:
   
  If I directly update with a primary key: 
   
  Long v_idLong = Long.valueOf( "55");
  
  Models model = new Models();
  model.setModelId(v_idLong);
  model.setModelname("Update New record IN Models");
   
  ModelsDAO modeldao = new ModelsDAO();
  modeldao.update(model);
   
  It is successful.
   
  Please reply that is what is problem and how to solv it. Thank you.
   
  Frank
   
   
   
   
  
  
 
   

 
---------------------------------
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.

Re: [Configuration] problems with changing the delimiter

Posted by Oliver Heger <ol...@oliver-heger.de>.
Ole Wendland wrote:
> Hello Guys,
> please tell me whats the problem with this delimiter.
> The Program is this one:
> 
> import org.apache.commons.configuration.*;
> import java.io.*;
> import java.util.List;
> 
> class SaveProperties
> {     public static void main( String[] args )
>  {
> 
>      try {           PropertiesConfiguration config = new
> PropertiesConfiguration("test.txt");
>         config.setListDelimiter('|');
>       
> System.out.println(System.out.println(config.getList("test").get(0));
> 
>    } catch (ConfigurationException e) {
>        // TODO Auto-generated catch block
>        e.printStackTrace();
>    }
>  }
> }
> 
> and the test.txt looks like this
> test = one|two|three
> 
> The output I expect should be "one" but he can't split the List and
> gives me  "one|two|three". When I use a comma as Delimiter is everything
> fine.
> What is my mistake?
> 
> Greetings Ole

You have to set the delimiter before you load the configuration. Follow
this pattern:

PropertiesConfiguration config = new PropertiesConfiguration();
config.setListDelimiter('|');
config.load("test.txt");

(There is a note about this behavior in the Javadocs for the
setListDelimiter() method in AbstractConfiguration.)

Oliver

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