3 Replies Latest reply on Jul 10, 2002 4:32 PM by Dain Sundstrom

    Postgres + home.create()

    Carlos Augusto Grahl Newbie

      Hi all!!

      Firstly, thank you for all replies to my other questions! :-))

      Now, a new one:

      I've installed successfully JBoss 3.0 + PostgreSQL. Then, I made three very simple entity beans (CMP), and a session bean which reads a text file and create the entity beans according to the data read. (With this, I import my text file to PostgreSQL database).

      Here is the code of the Session bean (some code ommited, leave only the relevant parts):

      tabmarhome = (TabMarHome) PortableRemoteObject.narrow(ctx.lookup("TabMar"), TabMarHome.class);
      BufferedReader in = new BufferedReader(new FileReader("c:\\eclipse\\workspace\\apuracao\\tabmar.dat"));
      String s = new String();
      while((s = in.readLine())!= null) {
      StringTokenizer st = new StringTokenizer(s, ",");
      while (st.hasMoreTokens()) {
      codesc = Integer.parseInt(st.nextToken());
      datmar = Integer.parseInt(st.nextToken());
      hormar = Integer.parseInt(st.nextToken());
      tabmarhome.create(codesc, datmar, hormar);
      }
      in.close();
      }

      When I look at the server log, JBoss made 2 SQL commands for every tabmarhome.create():

      1) Select count(*) from Tabmar where....
      2) Insert into Tabmar values(...)

      Is that correct?

      There's no way to ommit the "select count(*).." before the Insert? It's very time-expensive to do that.. And the performance is poor..

      Any ideas?

      Thank you in advance.

      Carlos Augusto Grahl