Struts, beans, and unique IDs

Hi,
I'm trying to capture info from a web form using Struts, and I have a ActionForm (bean?) for that. When submitted (or instantiated - I don't know the details of how or when exactly it's being created), I want that bean to somehow get assigned a uniqueID so I could locate it easily in a database later.
Where and when should I be doing this? Is it in the action class after the form has been submitted that I should assign ID to the bean (bean.setID(generatedInt); - but that's not good practice, I think), or inside the bean in its constructor? Or maybe there's a simple and clean way Struts can do this?
And generally, is there good info on how and when the bean is being created by Struts? From Struts docs I got an idea of a bean representing a form through which the data is being submitted. Is this so?

There are beans and then there are beans. They are used for many purposes.
Struts ActionForm beans are used to gather together and validate the data from a JSP page (or some other view) and present it to the Action. Those are the beans they were probably talking about in the struts docs.
Your business logic for the most part should be stored in different beans from these ActionForm beans.
Database properties don't always correspond directly to all the fields on a form and vice versa. The whole point is that these business beans are your model - they should not in any way be affected by the view.
On assigning Ids - my approach would be to have it in your business layer, rather than in the action class. That would mean that the beans could be usable outside of struts. Each individual class should be responsible for getting its id - ideally the first time it is saved.
Just my 2 cents,
evnafets

Similar Messages

  • JSP, BEANS AND DAO best practice... (and a little of STRUTS & JSTL)

    Hi,
    Want to get your opinion on how to really use bean and dao in jsp pages.
    Imagine that you wants to display a news list on the jsp index page for example.
    You've got a dao with method getLastNews(int size) which returns a Collection of News beans. Then with jstl or struts you iterate ove the collection to display the news in a formatted way.
    Easy to build collection with scriptlets & co but not very clean...
    What is the best way to call my dao and its method with a tag whithout using scriplets ?
    Thanks

    Yes this is the solution i use when the collection is displayed alone in a jsp page, but how do you do this when you include this collection in a page, and if you have other collections in other parts of the page ? Is there a clean solution of doing this in the jsp page? For example:
    <sometag:loadmycollection name="list"/>
    <logic:iterate id="myCollectionElement" name="list">
    Element Value: <bean:write name="myCollectionElement" />
    </logic:iterate>
    I know that i can write my own tag by if there is an existing solution...

  • Using EL variable in struts bean:message tag(not struts EL tag)

    Is there any work around to use an EL variable inside struts bean:message tag as key:
    I have like this:
    <bean:message key="${bean.keyName}"/>
    which is throwing error , I know this can be resolved by using struts-el tags but i cannot use them for specific reasons.
    I dont want to use bean:define tag to define my 'bean' and then use like this:
    <bean:message key="<%=bean.getKeyName%>"/> (this actually works, but i want to use EL variable)
    Is there any work around to use EL variable and make the message display on the jsp.
    i tried multiple ways like scriplets and jsp:useBean but nothing worked, Please let me know..
    Thanks in advance

    Im pretty sure that EL does not work in the normal struts tag unless its struts-el tag.Have you tried it?
    As I said, in a properly configured JSP2.0 container you can use EL expressions anywhere you could traditionally use a standard runtime expression <%= expr %>.
    What server are you using? What JSP version?
    The Struts-el tags were written so that you could use EL with struts in JSP1.2 containers.
    The c_rt tags were written so you could use runtime expressions with JSTL tags in JSP1.2 containers. Their use was discouraged even then. Now I consider their use absolutely unnecessary.
    Please read this thread: http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0
    Cheers,
    evnafets

  • Cannot insert more than 1 WSUS update source with different unique ids

    Hello LnG
    I am aware that are a whole bunch of forum threads on this error however little bit of additional help would be of great help, as I have nearly tracked this 'pain' down.
    Our environment: SCCM 2007 R3
    1 Central
    15 Primaries and a whole bunch of secondaries
    Single WSUS server
    OK, so we have just taken handover of this new account and still getting a hang of the creek and corners in the environment. We have about 1000 machines sitting in "Failed to download updates" state.  Error
    = 0x80040694
    WUAHandler.log:
    Its a WSUS Update Source type ({A2762CA9-9739-4260-9C3A-DC4B36122E16}), adding it
    Cannot insert more than 1 WSUS update source with different unique ids
    Failed to Add Update Source for WUAgent of type (2) and id ({A2762CA9-9739-4260-9C3A-DC4B36122E16}). Error = 0x80040694.
    Its a WSUS Update Source type ({BCB9D60B-2668-459B-BFFD-6DDD11AADC53}), adding it
    Existing WUA Managed server was already set (http://WSUSServername:8530), skipping Group Policy registration.
    Added Update Source ({BCB9D60B-2668-459B-BFFD-6DDD11AADC53}) of content type: 2
    WUAHandler
    Async searching of updates using WUAgent started.
    Checked the
    CI_UpdateSources table and found 2 Update sources  unique ids:
    {BCB9D60B-2668-459B-BFFD-6DDD11AADC53} Date Created 2011-01-11 03:47:52.000/Date Modified 2011-01-11 03:47:52.000
    and
    {A2762CA9-9739-4260-9C3A-DC4B36122E16} Date Created 2014-07-09 02:48:46.000 / Date Modified 2014-07-09 02:48:46.000
    My questions:
    Can I rely on the last modified/created date for inactive update source and delete it off the database? in this case can I delete {BCB9D60B-2668-459B-BFFD-6DDD11AADC53}?
    When i browsed to the registry location on the Central Server
    HKLM\Software\Wow6432Node\Microsoft\SMS\Components\SMS_WSUS_SYNC_MANAGER i saw the update source as {BCB9D60B-2668-459B-BFFD-6DDD11AADC53}.
    Does it imply that a stale record?
    Any help/guidance will be much appreciated :)

    Well!! My wsyncmgr.log  says  this: 
    Set content version of update source {BCB9D60B-2668-459B-BFFD-6DDD11AADC53} for site XX to 18
    Set content version of update source {BCB9D60B-2668-459B-BFFD-6DDD11AADC53} for site XX1 to 18
    Set content version of update source {BCB9D60B-2668-459B-BFFD-6DDD11AADC53} for site XX2 to 18
    Set content version of update source {BCB9D60B-2668-459B-BFFD-6DDD11AADC53} for site XX3 to 18
    Set content version of update source {BCB9D60B-2668-459B-BFFD-6DDD11AADC53} for site XX4 to 18
    Set content version of update source {BCB9D60B-2668-459B-BFFD-6DDD11AADC53} for site XX5to 1
    Set content version of update source {BCB9D60B-2668-459B-BFFD-6DDD11AADC53} for site XX6 to 18
    So, this is an active update source! ?? I cannnot uninstall and reinstall SUP currently. Any thoughts?? Any ody?

  • Jsp:include fails when referencing a struts bean:define bean

    When I request the jsp listed at the bottom, I get the following error:
              cannot resolve symbol
              symbol : variable pageTemplate
              The jsp works as is in both Tomcat and Resin.
              I know the pageTemplate bean gets defined by struts, because if I remove
              (1), I get the correct output of (2).
              Does WL precompile the pages differently than Tomcat/Resin?
              We know tiles can provide similar functionality, but for various reasons,
              this is the method that seems preferred.
              <%@ page contentType="text/html;charset=UTF-8" language="java" %>
              <%@ page import = "com.stabilia.site.*" %>
              <%@ page errorPage="/error.jsp" %>
              <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
              <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
              <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
              <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
                   <bean:define id="siteConfig" name="siteConfig" scope="session"
                        type="com.stabilia.site.SiteConfiguration"/>
                   <bean:define id="pageTemplate" name="siteConfig"
              property="currentPageTemplate"
                        type="com.stabilia.site.PageTemplate" scope="session"/>
                   (1)<jsp:include page="<%=pageTemplate.getTemplate()%>" />
                   (2)template:<bean:write name="pageTemplate" property="template"/>
              

    I know that in certain versions of WLS the Tag AT_END variables were not getting
              defined properly. Please contact support and ask for a patch referencing this
              with your current version.
              Sam
              Daren Desjardins wrote:
              > To be more specific, I found that I cannot use runtime expressions that
              > involve a bean defined by Struts. If the bean were declared in the
              > following way, it works.
              >
              > <%
              > SiteConfiguration siteconfig = (SiteConfiguration)
              > session.getAttribute(SiteConfiguration.SESSION_KEY);
              > PageTemplate pagetemplate = siteconfig.getCurrentPageTemplate();
              > %>
              > <jsp:include page="<%=pagetemplate.getTemplate()%>" flush="true"/>
              

  • Java beans and PJC's

    can any one give me the differences of java beans and pluggable java components.

    Pluggable Java Components (PJCs) are JavaBeans that are either embedded in the form as a separate object (Bean Area on the Layout Editor toolbar) or that act as a substitute for a Forms object such as an item or button. Incorporating PJCs will allow you to extend the capabilities of Forms and solve problems such as how to read and write to the client's file system, how to provide a Java spell checker for a Web form, how to implement timers that fire only on the client.
    You could find some examples at:
    http://otn.oracle.com/products/ids/daily/mar04.html
    Thanks,
    Rashmi.

  • Struts bean:message encoding help

    Hello, i am using Struts framework and have problems with resource files.
    I have two files for english and lithuanian.
    jsp file:
    <%@ page contentType="text/html; charset=Cp1257" pageEncoding="Cp1257"%>
    Developed by: <bean:message key="developer.name"/>
    So its echo bad string.
    Any ideas?

    I have had same problem but I have resolve it by both changing the encoding property of IDE(mine is NetBeans 3.6) to UTF-8 and
    put the line
    <%@page pageEncoding="UTF-8"  contentType="text/html; charset=UTF-8" %>on the top of jsp pages.
    But now I having some problems with formbean I hope I resolve it.
    You can follow it from here
    http://forum.java.sun.com/thread.jspa?threadID=698855

  • Metadata for namespace '/WEB-INF/tld/struts-bean.tld' is not loaded.

    What does this : "Metadata for namespace '/WEB-INF/tld/struts-bean.tld' is not loaded." mean? The message comes from a jsp and is displayed in the structure window.
    Anyone know how to restore the default layout to JDeveloper? Applications window has gone full screen width and I can not seem to get it bak to default Any ideas?
    Thanks
    Richard

    Metadata for namespace '/WEB-INF/tld/struts-bean.tld' is not loaded
    1. Add the struts.jar to the WEB-INF/lib directory.
    2. Add the struts-bean.tld to the WEB-INF directory.
    3. In the web.xml add
    <taglib>
    <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    </taglib>
    4. To the JSP add
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

  • Looking for struts bean:write   Equivalent function/ tag in jsf??

    Hi to all,
    I am quite new to jsf. Soi might be asking a stupid question.
    I just wanna to know is there an equivalent tag or simple scriplet that can provide the same function as strut <bean:write>?
    Thanks and regards,
    Chin Tat

    ok i am not a struts programmer but from a quick search i am assuming <bean:write> outputs in html the value of a property in your java bean?
    if this is the case then you simply use
    #{beanName.propertyName}
    i.e
    <h:outputText value="#{beanName.propertyName}"/>
    note your bean will have to be registered in you facesContext as a managed bean to do this (where beanName is the name of your managedBean)
    if bean:write doesn't do this sorry :) forget my answer

  • Help with struts bean tag

    I populated my data in a hashtable and it contains key & the values are in an arraylist of treemap. How do I display data using struts bean tag? Thanks.

    if you have an arraylist of maps why do you need three iterates?
    <logic:iterate id="treeMap" name="navTable">  //navTable is your ArrayList treeMap will be each map
         <logic:iterate id="element" name="treeMap">  //element is each element as it iterates through treeMap
                         key = <bean:write name="element" property="key" filter="false"/>
                         value = <bean:write name="element" property="value" filter="false"/>
             </logic:iterate>
    </logic:iterate>unless of course I missed something and you really need three iterates.
    of course you need a getNavTable() method, though you probably already have that.

  • Off topic: Database Unique IDs

    Hi folks,
    This is a little off-topic, but I figure that there may be other people out
    there whose Forte development would benefit from the discussion.
    I am currently building a development framework for our new software
    product. As part of that framework I'd like to include the facility for
    generating unique, user-invisible, integer database IDs.
    Now there is some doubt here that this is actually required and that the
    primary key should be whatever the programmer wants it to be, including
    multiple columns if necessary.
    I was wondering if anyone can give us some rules-of-thumb regarding
    the use of unique IDs as primary keys. Or if someone can point me to
    some on-line resources (or even a good book) that can guide us in this
    area.
    The arguments I have given for using integer IDs are:
    - Single, integer columns should be faster
    - User invisible integer ID allows editing/duplicates of all user-visible fields
    - Single, integer foreign keys would reduce storage requirements
    - Standardising on integer IDs would allow generic functionality built into
    framework
    - More object-oriented as objects have "built-in" unique identity
    I would appreciate any comments people have. We can take this
    discussion off-list if that is preferable.
    Cheers,
    Duncan Kinnear,
    McCarthy and Associates, Email: [email protected]
    PO Box 764, McLean Towers, Phone: +64 6 834 3360
    Shakespeare Road, Napier, New Zealand. Fax: +64 6 834 3369
    Providing Integrated Software to the Meat Processing Industry for over 10 years
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi folks,
    This is a little off-topic, but I figure that there may be other people out
    there whose Forte development would benefit from the discussion.
    I am currently building a development framework for our new software
    product. As part of that framework I'd like to include the facility for
    generating unique, user-invisible, integer database IDs.
    Now there is some doubt here that this is actually required and that the
    primary key should be whatever the programmer wants it to be, including
    multiple columns if necessary.
    I was wondering if anyone can give us some rules-of-thumb regarding
    the use of unique IDs as primary keys. Or if someone can point me to
    some on-line resources (or even a good book) that can guide us in this
    area.
    The arguments I have given for using integer IDs are:
    - Single, integer columns should be faster
    - User invisible integer ID allows editing/duplicates of all user-visible fields
    - Single, integer foreign keys would reduce storage requirements
    - Standardising on integer IDs would allow generic functionality built into
    framework
    - More object-oriented as objects have "built-in" unique identity
    I would appreciate any comments people have. We can take this
    discussion off-list if that is preferable.
    Cheers,
    Duncan Kinnear,
    McCarthy and Associates, Email: [email protected]
    PO Box 764, McLean Towers, Phone: +64 6 834 3360
    Shakespeare Road, Napier, New Zealand. Fax: +64 6 834 3369
    Providing Integrated Software to the Meat Processing Industry for over 10 years
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • Difference b/w index and unique

    Hi,
    Difference b/w index and unique?

    hi,
    The optional additions UNIQUE or NON-UNIQUE determine whether the key is to be unique or non-unique, that is, whether the table can accept duplicate entries. If you do not specify UNIQUE or NON-UNIQUE for the key, the table type is generic in this respect. As such, it can only be used for specifying types. When you specify the table type simultaneously, you must note the following restrictions:
    You cannot use the UNIQUE addition for standard tables. The system always generates the NON-UNIQUE addition automatically.
    You must always specify the UNIQUE option when you create a hashed table.
    INDEX:
    An index can be considered a copy of a database table that has been reduced to certain fields. This copy is always in sorted form. Sorting provides faster access to the data records of the table, for example using a binary search. The index also contains a pointer to the corresponding record of the actual table so that the fields not contained in the index can also be read.
    The primary index is distinguished from the secondary indexes of a table. The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database
    You can also create further indexes on a table in the ABAP Dictionary. These are called secondary indexes. This is necessary if the table is frequently accessed in a way that does not take advantage of the sorting of the primary index for the access.
    Indexes speed up data selection from the database. They consist of selected fields of a table, of which a copy is then made in sorted order. If you specify the index fields correctly in a condition in the WHERE or HAVING clause, the system only searches part of the index (index range scan).
    The system automatically creates the primary index. It consists of the primary key fields of the database table. This means that for each combination of fields in the index, there is a maximum of one line in the table. This kind of index is also known as UNIQUE.
    If you cannot use the primary index to determine the result set because, for example, none of the primary index fields occur in the WHERE or HAVINGclauses, the system searches through the entire table (full table scan). For this case, you can create secondary indexes, which can restrict the number of table entries searched to form the result set.
    You create secondary indexes using the ABAP Dictionary. There you can create its columns and define it as UNIQUE. However, you should not create secondary indexes to cover all possible combinations of fields.
    Only create one if you select data by fields that are not contained in another index, and the performance is very poor. Furthermore, you should only create secondary indexes for database tables from which you mainly read, since indexes have to be updated each time the database table is changed. As a rule, secondary indexes should not contain more than four fields, and you should not have more than five indexes for a single database table.
    If a table has more than five indexes, you run the risk of the optimizer choosing the wrong one for a particular operation. For this reason, you should avoid indexes with overlapping contents.
    Secondary indexes should contain columns that you use frequently in a selection, and that are as highly selective as possible. The fewer table entries that can be selected by a certain column, the higher that column’s selectivity. Place the most selective fields at the beginning of the index. Your secondary index should be so selective that each index entry corresponds to, at most, five percent of the table entries. If this is not the case, it is not worth creating the index. You should also avoid creating indexes for fields that are not always filled, where their value is initial for most entries in the table.
    If all of the columns in the SELECT clause are contained in the index, the system does not have to search the actual table data after reading from the index. If you have a SELECT clause with very few columns, you can improve performance dramatically by including these columns in a secondary index.
    What is the difference between primary index and secondary index?
    http://help.sap.com/saphelp_47x200/helpdata/en/cf/21eb2d446011d189700000e8322d00/frameset.htm
    A difference is made between Primary & Secondary indexes to a table. the primary index consists of the key fields of the table and a pointer to the non-keys-fields of the table. The Primary index is generated automatically when a table is created and is created in the datebase as the same times as the table. It is also possible to define further indexes to a table in the ABAP/4 dictionary, which are then referred to as Secondary indexes.
    Message was edited by:
            Roja Velagapudi

  • What is difference between Managed Bean and Backing Bean?

    What is difference between Managed Bean and Backing Bean? Please guide me how to create them and when to use them?
    Please post sample for both beans.

    Hi,
    managed beans and backing beans are quite the same in that the Java object is managed by the JavaServer Faces framework. Manage in this respect means instantiation. The difference is that backing beans contain component "binding" references, which managed beans usually don't. Do backing beans are page specific versions of managed beans.
    Managed beans are configured either in the faces-config.xml file, or using ADF Faces and ADFc, in the adfc-config.xml file
    Frank
    Edited by: Frank Nimphius on Jan 31, 2011 8:49 AM

  • Diff b/w primary key and unique key?

    what is the diff b/w primary key and unique key?

    Hi,
    With respect to functionality both are same.
    But in ABAP we only have Primary key for the Database tables declared in the Data Dictionary.
    Unique is generally is the term used with declaring key's for internal tables.
    Both primary and Unique keys can identify one record of a table.
    Regards,
    Sesh

  • Access path difference between Primary Key and Unique Index

    Hi All,
    Is there any specific way the oracle optimizer treats Primary key and Unique index differently?
    Oracle Version
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> Sample test data for Normal Index
    SQL> create table t_test_tab(col1 number, col2 number, col3 varchar2(12));
    Table created.
    SQL> create sequence seq_t_test_tab start with 1 increment by 1 ;
    Sequence created.
    SQL>  insert into t_test_tab select seq_t_test_tab.nextval, round(dbms_random.value(1,999)) , 'B'||round(dbms_random.value(1,50))||'A' from dual connect by level < 100000;
    99999 rows created.
    SQL> commit;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats(USER_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1565504962
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6915  consistent gets
            259  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> create index idx_t_test_tab on t_test_tab(col1);
    Index created.
    SQL> exec dbms_stats.gather_table_stats('USER_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1565504962
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6915  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> Sample test data when using Primary Key
    SQL> create table t_test_tab1(col1 number, col2 number, col3 varchar2(12));
    Table created.
    SQL> create sequence seq_t_test_tab1 start with 1 increment by 1 ;
    Sequence created.
    SQL> insert into t_test_tab1 select seq_t_test_tab1.nextval, round(dbms_random.value(1,999)) , 'B'||round(dbms_random.value(1,50))||'A' from dual connect by level < 100000;
    99999 rows created.
    SQL> commit;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats('USER_OWNER','T_TEST_TAB1',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab1;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1727568366
    | Id  | Operation         | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |             | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB1 | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6915  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> alter table t_test_tab1 add constraint pk_t_test_tab1 primary key (col1);
    Table altered.
    SQL> exec dbms_stats.gather_table_stats('USER_OWNER','T_TEST_TAB1',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab1;
    99999 rows selected.
    Execution Plan
    Plan hash value: 2995826579
    | Id  | Operation            | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |                | 99999 |   488K|    59   (2)| 00:00:01 |
    |   1 |  INDEX FAST FULL SCAN| PK_T_TEST_TAB1 | 99999 |   488K|    59   (2)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6867  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> If you see here the even though statistics were gathered,
         * In the 1st table T_TEST_TAB, the table is still using FULL table access after creation of index.
         * And in the 2nd table T_TEST_TAB1, table is using PRIMARY KEY as expected.
    Any comments ??
    Regards,
    BPat

    Thanks.
    Yes, ignored the NOT NULL part.Did a test and now it is working as expected
    SQL>  create table t_test_tab(col1 number not null, col2 number, col3 varchar2(12));
    Table created.
    SQL>
    create sequence seq_t_test_tab start with 1 increment by 1 ;SQL>
    Sequence created.
    SQL> insert into t_test_tab select seq_t_test_tab.nextval, round(dbms_random.value(1,999)) , 'B'||round(dbms_random.value(1,50))||'A' from dual connect by level < 100000;
    99999 rows created.
    SQL> commit;
    Commit complete.
    SQL>  exec dbms_stats.gather_table_stats('GREP_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL>  set autotrace traceonly
    SQL>  select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1565504962
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6912  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL>  create index idx_t_test_tab on t_test_tab(col1);
    Index created.
    SQL>  exec dbms_stats.gather_table_stats('GREP_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL>  select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 4115006285
    | Id  | Operation            | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |                | 99999 |   488K|    63   (2)| 00:00:01 |
    |   1 |  INDEX FAST FULL SCAN| IDX_T_TEST_TAB | 99999 |   488K|    63   (2)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6881  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL>

Maybe you are looking for

  • I can't open my windows live/ hotmail e-mails when using firefox but other browsers work

    i just downloaded mozilla firefox and it wont allow me to open my e mails. i have a windows live e mail. the page loads and lets me go to my inbox and other folders but i can't open e mails or delete them. if i use another browser like internet explo

  • Burning to folder and then to dvd

    Hello, I am getting into a complete mess trying to burn my project in PE7 to a folder ( can't even see "burn to folder" option!) I need to comlpete this project today so can u PLEASE give me the steps I need to take. I did look in forums, but still n

  • Can't edit the message popup in teststand 4.2.1

    Hi, I installed the 2010 version of TestStand on my PC. Everything has been fine until today. Every time i try to edit a property loader I get the following error: Error in cal to LoadPanelEx. Parent Panel Handel: 0 UIR File Name: PropertyLoaderUI.ui

  • "Tap to tweet" and "tap to post" options have gone in my notification centre

    I have the iPhone 5 and I noticed when I first had it that I did have the "tap to tweet" and "tap to post" options in my notification centre but they've somehow gone and I'm not sure why this is. Somehow the "share widget" option isn't in my notifica

  • How to use Form?

    Hi, I got some problems when using Form: java.lang.ClassCastException at com.sun.faces.taglib.html_basic.FormTag.setProperties(FormTag.java:160). Here is my jsp: <%@ page contentType="text/html; charset=ISO-8859-1" %> <%@ taglib uri="http://java.sun.