Collection of Strings

Is it possible to have a collection of strings? Using Toplink and JPA
For instance:
Collection<String> dataName;
it gives me Error
"is not a valid type for a serialized mapping"
Also is it possible to have nested collections?
Collection<Collection<int>> data;
Thanks

Both are valid. In JPA you could map them as @Basic and the value will be serialized into a binary column type. For the Collection<String> you could also use the TopLink DirectCollectionMapping to map this, this mapping type is not part of JPA, but you could define it through a DescriptorCustomizer, or using the @BasicCollection annotation or XML in EclipseLink.
You could also create an Entity class to wrap the String or nested Collection, and map it as a @OneToMany.
-- James : http://www.eclipselink.org

Similar Messages

  • CMP of Collection of Strings

    Hi there,
    I have an Entity EJB which has as one of it's fields a Collection of Strings. Is there anyway to CMP this field besides storing it as a BLOB?
    I've had a look through the documentation and I can't find a way, but it must be such a common scenario I find it hard to believe.
    Any help or comments appreciated!

    Hi John,
    As you mentioned, here's no direct way to store this Collection field. You might try to append all strings into a new string and store it in a CMP String field, depending on the maximum String size supported by your database. The Collection has to be transient. S1AS 8 will support CLOB fields.
    Regards,
    -- markus.

  • SQL Azure indexer support for Collection(Edm.String)

    Is there a plan to support "Collection(Edm.String)
    " with a SQL Azure indexer? Maybe via an XML type?
    Unless I'm misunderstanding the supported types
    https://msdn.microsoft.com/en-us/library/azure/dn946880.aspx
    It sort of fizzles out after "time, timespan" but I'm assuming it's Not Supported's all the way down

    http://feedback.azure.com/forums/263029-azure-search/suggestions/7189214-sql-azure-indexer-support-for-collection-edm-strin
    Was going to start there but just wanted to vet that it indeed wasn't there.... I realize it's a bit awkward and anti - sql storing data like that in a column and will probably annoy DBAs.
     Currently the data we'd use this for would be Customer phone numbers, addresses, VIN for vehicles, and some account numbers... So nothing super fancy...   Straight delimiters might get funky with addresses but maybe a standard backspace escape
    sequence or letting user use ascii hexcode if the delimiter is in the text..  
    For now we already have a comma separated SearchText field we've indexed for use with FTS and I just pointed an Edm.string at that column in our DB and it seems to pick up all the comma separated elements... But I'm guessing it's not as efficient as if it
    was stored in more specific collections.

  • Persisting collection of Strings - EJB,  TopLink

    I am a student and I have to write small java EE application.
    I am writing in NetBeans 5.5 and use Java Application Server, EJB 3.0 and TopLink.
    In my system, teachers make tasks (stored on server) and pupils have to solve them.
    Possible answers defined by teacher, while viewed by a pupil, have to in the same order, as the teacher defined. I think, list of strings would by the easiest solution to store possible answers.
    @Entity
    public class Task implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String question;
    private List possibleAnswers;
    public Task(String q, List a) {
    possibleAnswers = a;
    question = q;
    /* setters and getters */
    possibleAnswers is a list of Strings.
    When I left possibleAnswers unitialized, the task is persisted properly(just possibleAnswers is a null)
    The problem is, when I initialize list(with new ArrayList() or new LinkedList()), persisting fails. It doesn`t matter whether this list is empty or not.
    java.rmi.RemoteException: Transaction aborted
    I found this link:
    http://www.oracle.com/technology/products/ias/toplink/doc/10131/main/_html/relmapun010.htm#CHDHHGBG
    Can I use it in my project? How?

    What error do you get? You should see the exception in your server's log.
    Typically for a List you need to specify what it references, and how to map it.
    i.e.
    @Basic
    private List<String> possibleAnswers;
    This would serialize the List into a binary field in the database, which is what I would assume the default would do as well.
    You could also map it as a @OneToMany, but then you would need an Answer class instead of just a String.
    In TopLink you could map a collection of Strings to a seperate table using a DirectCollectionMapping, this mapping type is not part of JPA, but you could use a DescriptorCustomizer to add this mapping to your TopLink descriptor.

  • Are globals the best way to pass a collection of strings?

    I have an ATE application that is used on several models of the same
    product. The models have optioning commands and status screen layouts
    that use different terms for the same function. For example: "LBO" on
    one model might be labeled "EQ" on another. I capture the screen
    output as serial data and then parse it for the string I need to read.
    In order to use the same code on different models I have a config file
    that loads the correct strings into global variables based on the
    model I'm testing. The globals are then read by the sub-VIs. This
    works well, but I use over a hundred globals to do this and I worry
    that some day the overhead will catch up to me.
    Does anyone know a better way to do this? The re
    quirement is that the
    strings be kept in a central location for maintainability, yet be
    accessable to several sub-VIs.
    I'm running LV 6i, but I could upgrade to 6.1 if necessary.
    Ed

    Could you pass them in via a cluster of strings?
    "Ed Ward" wrote in message
    news:[email protected]..
    > I have an ATE application that is used on several models of the same
    > product. The models have optioning commands and status screen layouts
    > that use different terms for the same function. For example: "LBO" on
    > one model might be labeled "EQ" on another. I capture the screen
    > output as serial data and then parse it for the string I need to read.
    >
    > In order to use the same code on different models I have a config file
    > that loads the correct strings into global variables based on the
    > model I'm testing. The globals are then read by the sub-VIs. This
    > works well, but I use over a hundred glob
    als to do this and I worry
    > that some day the overhead will catch up to me.
    >
    > Does anyone know a better way to do this? The requirement is that the
    > strings be kept in a central location for maintainability, yet be
    > accessable to several sub-VIs.
    >
    > I'm running LV 6i, but I could upgrade to 6.1 if necessary.
    >
    > Ed

  • ImmutableArrayList default for Map Long, Collection String

    Hi,
    There are a few topics out there about the com.tangosol.util.ImmutableArrayList default, but the actual fix still seems a bit unclear to me.
    In my example there is a Map with each entry containing a Collection of Strings (i.e. Map<Long, Collection<String>>). Objects will be placed in the Map as ArrayLists, but they seem to come out as ImmutableArrayLists.
    The Oracle site mentions wrapping the Collection (http://extranet.tangosol.com/display/COH35UG/Best+Practices+for+Coherence+Extend).
    There is another Oracle forum post that suggests using more general classes (List instead of ArrayList). (Serialize an ArrayList<ArrayList>
    It seems like you have to make a new collection anytime you wish to reserialize the object. Is there a better way?
    Thanks for taking the time,
    Mike

    This problem comes up for us when persisting documents. We are torn between saving as XML vice saving a normalized object model or something else: like your database solution.
    Since you have already designed the database, then you can reverse out the TopLink class from that database design in the mapping workbench. You then have to perform a transform in the middle tier to extract your business model.
    Alternatively, if you want your business model to map via ORM to the data model, then you would have a database design that more closely maps the business model design then you get three tables:
    TopLevel
    Integer primaryKey; //This table may just have the PK
    SetMap theSets;
    SetMap
    TopLevel parent; //FK to the Parent table
    Long primaryKey; //Assumes the Longs are globally unique. If not, the PK will include the parent
    SetList theSet;
    SetList
    SepMap parent; //Part of PK. This can get complicated if the PK migrates all the way from TopLevel. We insert a surrogate key at this point.
    String setMember; //Rest of PK
    The database constraints ensure that the SetList is unique. The equivalent string may exist in different SetMaps, but may not be duplicated for a particular parent.

  • Comparing Collection object with a string

    Hi everyone,
    There is my problem: I have a program that generate all possible combinations of a certain number of letters for example: -ABC- will gives A, B, C, AB, AC, BC, ABC. Everything is fine at this point. But then the user can input a string like "AB" and I have to tell him if this string is contained in the generated set. My set is in a Collection, but when I used : LetterCombination.Contains(TextString), it returns always false. Even if I know that the string is contained in the set.
    Here is the code to generate the set:
    public class Recursion
         Collection LetterCombination;
    /*String Letters is the letters which I have to generate the combination, and
    the LetterNumber is the number of letters contained in my string.*/
         public Recursion(Set ItemLetters, String Letters, int LetterNumbers)
              ItemLetters = new TreeSet();
    String[] Token = Letters.split(" ");
    /*Adding the letters in the TreeSet*/
    for (int i = 0; i < LetterNumbers; i++)
         ItemLetters.add(Token);
    LetterCombination = BuildLetterSet(ItemLetters);
    private Collection BuildLetterSet(Set ItemLetters)
    Set NotUsedYet = new TreeSet();
    Set thisPowerSet = new TreeSet();
    Collection Letterresult = new ArrayList();
    NotUsedYet.addAll(ItemLetters);
    BuildByRecursion(NotUsedYet, thisPowerSet, Letterresult);
    return Letterresult;
    private void BuildByRecursion(Set notUsedYet, Set thisPowerSet, Collection result)
    if(notUsedYet.isEmpty())
    if(!thisPowerSet.isEmpty())
    Set copy = new TreeSet();
    copy.addAll(thisPowerSet);
    result.add(copy);
    return;
    Object item = notUsedYet.iterator().next();
    notUsedYet.remove(item);
    BuildByRecursion(notUsedYet, thisPowerSet, result);
    thisPowerSet.add(item);
    BuildByRecursion(notUsedYet, thisPowerSet, result);
    thisPowerSet.remove(item);
    notUsedYet.add(item);
    And if I print out the LetterCombination collection, it gives me:
    [C]
    [B, C]
    [A]
    [A, C]
    [A, B]
    [A, B, C]
    Which are the good combination needed. But I really don't understand how to compare this collection with the string entered by the user.
    I'm really lost. can somebody help me! Thanks in advance...

    You don't show where you call this constructor, or what your arguments are:
    public Recursion(Set ItemLetters, String Letters, int LetterNumbers)
       ItemLetters = new TreeSet();
       String[] Token = Letters.split(" ");
       /*Adding the letters in the TreeSet*/
       for (int i = 0; i < LetterNumbers; i++)
          ItemLetters.add(Token[ i ]);
       LetterCombination = BuildLetterSet(ItemLetters);
    }But, the constructor doesn't make sense, anyway. itemLetters is immediately set to a new TreeSet, so whatever you passed in (if anything) for the first argument is unchanged by the constructor (and the new TreeSet is lost when you finish the constructor). Also, you split your input Letters on space, but rely on LetterNumbers for the length of the split array (which may or may not be accurate). Why not do a 'for' loop testing for "i < Token.length", and eliminate LetterNumbers parameter? Your input for the second parameter to this constructor would have to be "A B C D" (some letters delimited by spaces). Your constructor only needs one parameter--that String.
    The capitalization of your variables doesn't follow standard coding conventions. Your code is hard to read without the "code" formatting tags (see "Formatting Tips"/ [ code ] button above message posting box).

  • Oracle, Null and empty Strings

    Currently I'm facing problems with a class, which contains a String, which
    is set to "" (empty String).
    When the class is persistent, oracle writes null to the table column
    (which seems to be common oracle behaviour) and when retrieving the class,
    the field is set to null as well, giving me a lot of null-pointer
    exceptions.
    Anyway ... I can cope with that (just a lot of extra work)
    far worse is the problem, wenn searching objects, that have this field set
    to "" oder null.
    Oracle can't find the records because JDO creates Querys "where
    string=null" or "where string=''" , where oracle expects "where string is
    null" to find the records.
    Is there a workaround or solution ?

    Yeah, that would work as well, thx, but since I have to cope with
    null-Strings now everywhere in my program, it doesn't hurt just to forbid
    empty strings on the program side.
    In future times I'll test on Oracle first, then porting to DB/2 - this way
    I suppose work is far less to garant compability.
    Nevertheless ... having to set the bankcode into quotes is a kodo bug in
    my opinion.
    Kodo knows the type of classfields (in this case string) and shouldn't
    send the parameter as a BigDecimal to the database.
    Given that, and having only bankcodes of null (only neccesary when using
    Oracle), the method would look like:
    public Collection getAccounts (String bankCode)
    throws Exception
    return getAccounts (Account.class, "bankcode=="+bankcode);
    which is how a transparent persistent layer, um, should be , um , I mean
    ... just transparent ;-D
    Marc Prud'hommeaux wrote:
    Stefan-
    Couldn't you just do something like:
    public Collection getAccounts (String bankCode)
    throws Exception
    String filter;
    if (bankCode == null || bankCode.length () == 0)
    filter = "(bankCode == null || bankCode == "")";
    else
    filter = "bankCode == "" + bankCode + """;
    return getAccounts (Account.class, filter);
    If I understand the problem correctly, this should work for all the
    databases.
    In article <[email protected]>, Stefan wrote:
    What operations are you performing to cause this SQL to be issued? You
    say you are having trouble removing objects, but this is clearly not a
    DELETE statement. Is this the SQL that is issued when looking up
    objects by identity?I'm not removing objects, I was removing just quotes from parameters ;-)
    A string column... is it also represented as a string field in your class?Yeah ... just to give you an impression of the code:
    First we have a class, representing a bank account:
    public class Account {
    private AccountMgr myAccountMgr;
    private String bankCode;
    private String id;
    Note, that in nearly all cases bankCode will be a number or null.
    I have a second class "AccountMgr", which does all of the persistant stuff
    (seaching, making persistent etc.)
    This class has two methods, one versatile (protected) to retrieve accounts
    by a given filterString and one who just returns accounts by bankCode,
    building the expected filterstring. Here is my current working version:
    public class AccountMgr {
    public Collection getAccounts(String bankCode) throws Exception {
    if (bankCode!=null) {
    if (bankCode.equals("")) {
    throw new Exception("check code, bankCode='' not allowed to get
    same behavior from DB2 and Oracle");
    // if set, quote the bankCode
    bankCode="""+bankCode+""";
    return getAccounts(Account.class,"bankCode=="+bankCode);
    protected Collection getAccounts(Class accountClass, String filterAdd)
    throws Exception {
    PersistenceManager pm = MyHelper.getPersistenceManager();
    String filter="";
    if (filterAdd!=null && !filterAdd.trim().equals("")) {
    filter+=filterAdd + " && ";
    filter += "myAccountMgr==_accMgr";
    Query query = pm.newQuery(accountClass, filter);
    query.declareParameters("AccountMgr _accMgr");
    return (Collection) query.execute(this);
    As you can see, in the first method I have to set the bankCode into
    quotes, when it's not null.
    This is because otherwise a filter like "bankCode=1234" will be translated
    in a way, where 1234 is send as a BigDecimal to the database:
    [...] executing statement <4239745>: (SELECT [...] FROM JDO_ACCOUNT t0
    WHERE t0.BANKCODE = ? : [reused=1;params={(BigDecimal) 1234}]
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Using a Collection of beans to store a result set help.

    Does anyone have any sample code on the subject? This is something I wrote up, but I wanted feedback, and also an example of how to retreive data out of the array of beans in jsp
    package beanpersonal;
    import beandatabase.DBConnection;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    import java.util.Collection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    public class PersonNew {
    public PersonNew() { }
    public Collection getPersondata( String alias, String password ) {
    Connection conn = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
    Collection retValue = new ArrayList();
    String query = "SELECT * FROM person WHERE (alias = ?, password = ?)";
    try {
    conn = DBConnection.getDBConnection();
    stmt = conn.prepareStatement( query );
    stmt.setString( 1, alias );
    stmt.setString( 2, password );
    rs = stmt.executeQuery();
    while (rs.next()) {
    PersonalInfo beanrow = new PersonalInfo();
    beanrow.setAlias(rs.getString("alias"));
    beanrow.setPassword(rs.getString("password"));
    retValue.add(beanrow);
    return retValue;
    catch( SQLException sqle ) {
    //sqle.printStackTrace();
    //throw new ApplicationSpecficException("Cannot query db", sqle);
    throw new RuntimeException(sqle);
    finally {
    try {if (rs != null) rs.close();} catch (SQLException e) {}
    try {if (stmt != null) stmt.close();} catch (SQLException e) {}
    try {if (conn != null) conn.close();} catch (SQLException e) {}
    }

    sorry i only view the codes, but don't read it as a whole maybe this codes can help you..
    jsp:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@page import="java.util.*,mypackage.TestBean"%>
    <%
    String name = request.getParameter("name")!=null?request.getParameter("name"):"";
    String age = request.getParameter("age")!=null?request.getParameter("age"):"";
    System.out.println(name);
    System.out.println(age);
    Collection col = new ArrayList();
    col = (Collection)session.getAttribute("col")!=null?(Collection)session.getAttribute("col"):new ArrayList();
    TestBean tBean = new TestBean();
    if(!name.equals(""))
      tBean.setName(name);
    if(!age.equals(""))
      tBean.setAge(age);
    if(!age.equals("") || !name.equals(""))
      col.add(tBean);
    session.setAttribute("col",col);
    %>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>untitled</title>
      </head>
      <body>
        <form>
          <table cellspacing="0" cellpadding="0" border="1" width="200">
            <tr>
              <td>Name</td>
              <td>
                <input type="text" name="name"/>
              </td>
            </tr>
            <tr>
              <td>Age</td>
              <td>
                <input type="text" name="age"/>
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <input type="submit" value="Submit"/>
              </td>
            </tr>
          </table>
          <%
          if(col.size()>0){
          Iterator iter = col.iterator();
          %>
          <table cellspacing="0" cellpadding="0" border="1" width="200">
            <tr>
              <td>
                NAME
              </td>
              <td>
                AGE
              </td>
             </tr>
            <%while(iter.hasNext()){
              tBean = (TestBean)iter.next();
            %>
              <tr>
                <td>
                  <%=tBean.getName()%>
                </td>
                <td>
                  <%=tBean.getAge()%>
                </td>
               </tr>
            <%}%>
          </table>
          <%}%>
        </form>
      </body>
    </html>TestBean.java
    package mypackage;
    public class TestBean
      private String name;
      private String age;
      public TestBean()
      public String getName()
        return name;
      public void setName(String name)
        this.name = name;
      public String getAge()
        return age;
      public void setAge(String age)
        this.age = age;
    }

  • Easy way to create a list of strings in an object?

    I'm trying to create a HashSet of Strings but I don't want to have to add each string to the HashSet. There is a constructor for HashSet that allows you to give it a Collection. But how can I create a Collection of String other than having to add each string? Can I just :
    HashSet hs = new HashSet("String1", "String2", "String3", "String4");
    ?

    This programming problem is as old as the hills, and there are a zillion ways to do it. One of the simplest is by using String.split. Example:   String separator = "[^\\w]+";
       String string = "I think, therefore I am; or maybe not. What do you think?";
       String[] array = string.split(separator);
       System.out.println("String    : \"" + string + "\"");
       System.out.println("Word count: " + array.length + " words.");The key is the String separator. This is what is known as a "regular expression." It looks pretty obtuse (and is); do some research on regular expressions to figure out it means.
    This example does not account for a few special cases, such as words split between lines with hyphens, and perhaps words enclosed in double quotes. That is left as an exercise for the reader.

  • For Loop in Struts ?(without Collections)

    Hi all,
    Pls tell me how can v use FOR LOOP IN JSP STRUTS without using scriplets and collections .
    suppose i want to display 20 times "hello world "in jsp .How can i display it using STRUTS as conventionally scriplets are not allowed in it.
    and Iterator is only for Collections .
    thanx

    TestBean.java
    * $Id: TestBean.java 54929 2004-10-16 16:38:42Z germuska $
    * Copyright 1999-2004 The Apache Software Foundation.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    * http://www.apache.org/licenses/LICENSE-2.0
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    package org.apache.struts.webapp.exercise;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.Vector;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.util.LabelValueBean;
    * General purpose test bean for Struts custom tag tests.
    * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
    public class TestBean extends ActionForm {
    // ------------------------------------------------------------- Properties
    * A collection property where the elements of the collection are
    * of type <code>LabelValueBean</code>.
    private Collection beanCollection = null;
    public Collection getBeanCollection() {
    if (beanCollection == null) {
    Vector entries = new Vector(10);
    entries.add(new LabelValueBean("Label 0", "Value 0"));
    entries.add(new LabelValueBean("Label 1", "Value 1"));
    entries.add(new LabelValueBean("Label 2", "Value 2"));
    entries.add(new LabelValueBean("Label 3", "Value 3"));
    entries.add(new LabelValueBean("Label 4", "Value 4"));
    entries.add(new LabelValueBean("Label 5", "Value 5"));
    entries.add(new LabelValueBean("Label 6", "Value 6"));
    entries.add(new LabelValueBean("Label 7", "Value 7"));
    entries.add(new LabelValueBean("Label 8", "Value 8"));
    entries.add(new LabelValueBean("Label 9", "Value 9"));
    beanCollection = entries;
    return (beanCollection);
    public void setBeanCollection(Collection beanCollection) {
    this.beanCollection = beanCollection;
    * A multiple-String SELECT element using a bean collection.
    private String[] beanCollectionSelect = { "Value 1", "Value 3",
    "Value 5" };
    public String[] getBeanCollectionSelect() {
    return (this.beanCollectionSelect);
    public void setBeanCollectionSelect(String beanCollectionSelect[]) {
    this.beanCollectionSelect = beanCollectionSelect;
    * A boolean property whose initial value is true.
    private boolean booleanProperty = true;
    public boolean getBooleanProperty() {
    return (booleanProperty);
    public void setBooleanProperty(boolean booleanProperty) {
    this.booleanProperty = booleanProperty;
    * A multiple-String SELECT element using a collection.
    private String[] collectionSelect = { "Value 2", "Value 4",
    "Value 6" };
    public String[] getCollectionSelect() {
    return (this.collectionSelect);
    public void setCollectionSelect(String collectionSelect[]) {
    this.collectionSelect = collectionSelect;
    * A double property.
    private double doubleProperty = 321.0;
    public double getDoubleProperty() {
    return (this.doubleProperty);
    public void setDoubleProperty(double doubleProperty) {
    this.doubleProperty = doubleProperty;
    * A boolean property whose initial value is false
    private boolean falseProperty = false;
    public boolean getFalseProperty() {
    return (falseProperty);
    public void setFalseProperty(boolean falseProperty) {
    this.falseProperty = falseProperty;
    * A float property.
    private float floatProperty = (float) 123.0;
    public float getFloatProperty() {
    return (this.floatProperty);
    public void setFloatProperty(float floatProperty) {
    this.floatProperty = floatProperty;
    * Integer arrays that are accessed as an array as well as indexed.
    private int intArray[] = { 0, 10, 20, 30, 40 };
    public int[] getIntArray() {
    return (this.intArray);
    public void setIntArray(int intArray[]) {
    this.intArray = intArray;
    private int intIndexed[] = { 0, 10, 20, 30, 40 };
    public int getIntIndexed(int index) {
    return (intIndexed[index]);
    public void setIntIndexed(int index, int value) {
    intIndexed[index] = value;
    private int intMultibox[] = new int[0];
    public int[] getIntMultibox() {
    return (this.intMultibox);
    public void setIntMultibox(int intMultibox[]) {
    this.intMultibox = intMultibox;
    * An integer property.
    private int intProperty = 123;
    public int getIntProperty() {
    return (this.intProperty);
    public void setIntProperty(int intProperty) {
    this.intProperty = intProperty;
    * A long property.
    private long longProperty = 321;
    public long getLongProperty() {
    return (this.longProperty);
    public void setLongProperty(long longProperty) {
    this.longProperty = longProperty;
    * A multiple-String SELECT element.
    private String[] multipleSelect = { "Multiple 3", "Multiple 5",
    "Multiple 7" };
    public String[] getMultipleSelect() {
    return (this.multipleSelect);
    public void setMultipleSelect(String multipleSelect[]) {
    this.multipleSelect = multipleSelect;
    * A nested reference to another test bean (populated as needed).
    private TestBean nested = null;
    public TestBean getNested() {
    if (nested == null)
    nested = new TestBean();
    return (nested);
    * A String property with an initial value of null.
    private String nullProperty = null;
    public String getNullProperty() {
    return (this.nullProperty);
    public void setNullProperty(String nullProperty) {
    this.nullProperty = nullProperty;
    * A short property.
    private short shortProperty = (short) 987;
    public short getShortProperty() {
    return (this.shortProperty);
    public void setShortProperty(short shortProperty) {
    this.shortProperty = shortProperty;
    * A single-String value for a SELECT element.
    private String singleSelect = "Single 5";
    public String getSingleSelect() {
    return (this.singleSelect);
    public void setSingleSelect(String singleSelect) {
    this.singleSelect = singleSelect;
    * String arrays that are accessed as an array as well as indexed.
    private String stringArray[] =
    { "String 0", "String 1", "String 2", "String 3", "String 4" };
    public String[] getStringArray() {
    return (this.stringArray);
    public void setStringArray(String stringArray[]) {
    this.stringArray = stringArray;
    private String stringIndexed[] =
    { "String 0", "String 1", "String 2", "String 3", "String 4" };
    public String getStringIndexed(int index) {
    return (stringIndexed[index]);
    public void setStringIndexed(int index, String value) {
    stringIndexed[index] = value;
    private String stringMultibox[] = new String[0];
    public String[] getStringMultibox() {
    return (this.stringMultibox);
    public void setStringMultibox(String stringMultibox[]) {
    this.stringMultibox = stringMultibox;
    * A String property.
    private String stringProperty = "This is a string";
    public String getStringProperty() {
    return (this.stringProperty);
    public void setStringProperty(String stringProperty) {
    this.stringProperty = stringProperty;
    * An empty String property.
    private String emptyStringProperty = "";
    public String getEmptyStringProperty() {
    return (this.emptyStringProperty);
    public void setEmptyStringProperty(String emptyStringProperty) {
    this.emptyStringProperty = emptyStringProperty;
    * A single-String value for a SELECT element based on resource strings.
    private String resourcesSelect = "Resources 2";
    public String getResourcesSelect() {
    return (this.resourcesSelect);
    public void setResourcesSelect(String resourcesSelect) {
    this.resourcesSelect = resourcesSelect;
    * A property that allows a null value but is still used in a SELECT.
    private String withNulls = null;
    public String getWithNulls() {
    return (this.withNulls);
    public void setWithNulls(String withNulls) {
    this.withNulls = withNulls;
    * A List property.
    private List listProperty = null;
    public List getListProperty() {
    if (listProperty == null) {
    listProperty = new ArrayList();
    listProperty.add("dummy");
    return listProperty;
    public void setListProperty(List listProperty) {
    this.listProperty = listProperty;
    * An empty List property.
    private List emptyListProperty = null;
    public List getEmptyListProperty() {
    if (emptyListProperty == null) {
    emptyListProperty = new ArrayList();
    return emptyListProperty;
    public void setEmptyListProperty(List emptyListProperty) {
    this.emptyListProperty = emptyListProperty;
    * A Map property.
    private Map mapProperty = null;
    public Map getMapProperty() {
    if (mapProperty == null) {
    mapProperty = new HashMap();
    mapProperty.put("dummy", "dummy");
    return mapProperty;
    public void setMapProperty(Map mapProperty) {
    this.mapProperty = mapProperty;
    * An empty Map property.
    private Map emptyMapProperty = null;
    public Map getEmptyMapProperty() {
    if (emptyMapProperty == null) {
    emptyMapProperty = new HashMap();
    return emptyMapProperty;
    public void setEmptyMapProperty(Map emptyMapProperty) {
    this.emptyMapProperty = emptyMapProperty;
    // --------------------------------------------------------- Public Methods
    * Reset the properties that will be received as input.
    public void reset(ActionMapping mapping, HttpServletRequest request) {
    booleanProperty = false;
    collectionSelect = new String[0];
    intMultibox = new int[0];
    multipleSelect = new String[0];
    stringMultibox = new String[0];
    if (nested != null)
    nested.reset(mapping, request);
    }

  • Splitting string values in query

    all,
    i cant remember this but my problem is like i have a collection of string values passed to my query like "X234234:X23466:X03287:X457675" , so my query should be able to split each data value and use in the filter as below,
    select * from emp where EmpID in ("X234234:X23466:X03287:X457675")
    so how do i split every individual value and pass in the filter?
    thank you.

    Gor_Mahia wrote:
    onedbguru
    I'll revisit and marks acordingly i.e helpful but the other solution worked for me...thank you.It may have worked for you, but TABLE(XMLSEQUENCE is deprecated functionality so should be avoided.
    That's what happens when you take a 'correct' answer on face value rather than actually reading up on it and understanding if it really is a correct answer.
    The issue you have described is the "Varying IN list" issue which is commonly asked here, and Tom Kyte's blog on it is a suitable reference for dealing with it.
    Other methods are described in the FAQ: {message:id=9360009}
    You would be better to re-visit the solutions and pick one that is better, that doesn't use deprecated functionality.

  • Collections.sort()

    HI all
    I am re-writing a program which I wrote earlier which takes a list
    1 Joanne Smith and Lionel Brown
    2 Augustus Belcher
    3 Fatima Bacon and Gaynor White
    4 Celina Simmons and Rupert Rodgers-Smythe
    5 Ahmed Hussain
    6 Samuel Peacock and Sarah Peacock
    7 Hsin Cheng Liu
    8 Blanche Peacock and Harry Peacock
    and outputs
    1 Joanne Smith and Lionel Brown
    3 Fatima Bacon and Gaynor White
    5 Ahmed Hussain
    7 Hsin Cheng Liu
    8 Blanche Peacock and Harry Peacock
    6 Samuel Peacock and Sarah Peacock
    4 Celina Simmons and Rupert Rodgers-Smythe
    2 Augustus Belcher
    My brief is
    Create a class called DeliveryHouseDetails, which is Comparable with itself. This will
    store a house number in an instance variable, and the person name details in another. It
    will have an accessor method to obtain the person names. It will also have another in-
    stance method, compareTo(), which orders DeliveryHouseDetails objects by delivery
    order.
    Copy your StreetOrder class from the previous version, and modify it so that it creates a
    DeliveryHouseDetails object for each input line and stores it in the ArrayList. You can
    simply count the lines to obtain the house number ? there is no need to extract it from the details
    on the line. After loading the details the program will use sort() from the Collections class
    to sort them, then it can print them out by looping through them all, and extracting the person
    details.
    My code thus far
    public class DeliveryHouseDetails<ArrayType extends Comparable<ArrayType>>
       private int houseNumber;
       private String nameDetails;
       public DeliveryHouseDetails(String requiredNameDetails)
        nameDetails = requiredNameDetails;
      }//constructor
      public String getNamesDetails()
        return nameDetails;
      public int compareTo(int other)
        if((houseNumber % 2 == 1)&&(other % 2 ==1))
          return houseNumber - other;
        else if((houseNumber % 2 == 0)&& (other % 2 == 0))
          return (other - houseNumber);
        else if(houseNumber % 2 ==1)
          return -1;
        else
          return -1;
      public boolean equals(Object other)
        if (this.equals(other))
          return houseNumber == ((DeliveryHouseDetails)other).houseNumber;
        else
          return super.equals(other);
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    public class StreetOrderA
      public static void main(String [] args)
        String inputFileName = args[0];
        String outputFileName = args[1];
        ArrayList<String> lineList = new ArrayList<String>();
        String line;
        String item;
        try
        BufferedReader in=new BufferedReader(new FileReader(inputFileName));
        PrintWriter out=new PrintWriter(new FileWriter(outputFileName)); 
        if(args.length!=2)
          throw new ArrayIndexOutOfBoundsException("you have supplied"
                                +" the wrong no of arguments");
        while((line = in.readLine()) != null)
            item = new DeliveryHouseDetails(line);
          for(int index =0; index<=lineList.size();index++)
            lineList.add(item);
          Collections.<String>sort(lineList);
          for(int index =0; index<=lineList.size();index++)
            out.println(lineList.get(index));
          in.close();
          out.close();
       catch (FileNotFoundException e)
          System.out.println("Can't find the file, please enter a valid file");
         System.out.println("Exception"+e.getMessage());
           System.err.println(e); 
        catch (IOException e)
          System.err.println(e);
        catch (ArrayIndexOutOfBoundsException e)
          System.out.println("Supply two filenames");
          System.out.println("Exception message"+ e.getMessage());
          System.err.println(e);
    }Any help is appreciated !!
    Edited by: bigdoggy on Apr 6, 2008 12:34 PM

    Hi
    this is my StreetOrder code, updated from earlier but without the import statements and catch statements from before
    public static void main(String [] args)
        String inputFileName = args[0];
        String outputFileName = args[1];
        ArrayList<DeliveryHouseDetails> lineList
          = new ArrayList<DeliveryHouseDetails>();
        String line;
        try
        BufferedReader in=new BufferedReader(new FileReader(inputFileName));
        PrintWriter out=new PrintWriter(new FileWriter(outputFileName));  
        if(args.length!=2)
          throw new ArrayIndexOutOfBoundsException("you have supplied"
                                  +" the wrong no of arguments");
        while((line = in.readLine()) != null)
            DeliveryHouseDetails item = new DeliveryHouseDetails(line);
          for(int index =0; index<=lineList.size();index++)
            lineList.add(item);
          Collections.<String>sort(lineList);
          for(int index =0; index<=lineList.size();index++)
            out.println(lineList.get(index));
          in.close();
          out.close();

  • Contains Queries on Empty Collections

    I'm running into the following problem when attempting a JDO query which
    uses the .contains() operator on multiple collections, where one of the
    collections is empty.
    My class contains two vectors, both of which contain strings. I want to run
    a query that returns all instances of TestClass that contain a certain
    string in one of the two lists. I have done roughly what is outlined below.
    1) The class looks like:
    public class TestClass
    private Vector _collection1;
    private Vector _collection2;
    2) The metadata in system.jdo looks like:
    <class name="TestClass">
    <field name="_collection1">
    <collection element-type="java.lang.String"/>
    </field>
    <field name="_collection2">
    <collection element-type="java.lang.String"/>
    </field>
    </class>
    3) I construct the query as follows:
    // pm is the existing persistence manager
    Query query = pm.newQuery();
    query.setClass( TestClass.class );
    query.setCandidates( pm.getExtent( TestClass.class, true ) );
    query.setFilter( "_collection1.contains( string ) ||
    _collection2.contains( string )" );
    query.declareParameters( "String string" );
    Collection results = (Collection) query.executeWithArray( new Object[]
    { "searchString" } );
    4) The resulting SQL query (for SQL/Server) looks like:
    SELECT DISTINCT
    t0.JDOIDX,
    t0.JDOCLASSX,
    t0.JDOLOCKX
    FROM
    TESTCLASS__COLLECTION2X t2,
    TESTCLASSX t0,
    TESTCLASS__COLLECTION1X t1
    WHERE
    t1.COLLECTION1X = 'searchString'
    OR (t2.COLLECTION2X = 'searchString')
    AND t0.JDOIDX = t1.JDOIDX
    AND t0.JDOIDX = t2.JDOIDX
    Suppose that the target string is located in the first collection of some
    instance of TestClass. Also suppose that there are no strings in the second
    collection. Under these circumstances, the query will not return this
    instance.
    Is there a way to work around this other than running two separate queries?
    Is this a bug or is this the expected behaviour?
    Any help on this is much appreciated.
    Regards,
    Sasha Haghani.

    Hi David,
    I've tried this approach as well and am now getting a different error.
    Using:
    1) query filter: "( _collection1.contains( var ) && var == param ) || (
    _collection2.contains( var ) && var == param )"
    2) parameter string: "String param"
    3) variable string: "String var"
    4) parameters: new Object[] { "value" }
    The following exception raised is:
    com.techtrader.modules.jdo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=SELECT
    t0.JDOIDX, t0.JDOCLASSX, t0.JDOLOCKX FROM TESTCLASSX t0 WHERE variable =
    'value' OR (*variable* = 'value')] Line 1: Incorrect syntax near '*'.
    Severity 15, State 1 <rest of exception message omitted>
    at
    com.techtrader.modules.jdo.impl.jdbc.runtime.JDBCFieldData.load(JDBCFieldDat
    a.java:127)
    at
    com.techtrader.modules.jdo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuer
    y.java:33)
    at
    com.techtrader.modules.jdo.query.QueryImpl.executeWithMap(QueryImpl.java:330
    at
    com.techtrader.modules.jdo.query.QueryImpl.executeWithArray(QueryImpl.java:3
    93)
    As you can see from above, the generated SQL statement looks like:
    SELECT
    t0.JDOIDX,
    t0.JDOCLASSX,
    t0.JDOLOCKX
    FROM
    TESTCLASSX t0
    WHERE
    variable = 'value'
    OR (*variable* = 'value')
    Additionally, if I change the filter to "( (_collection1.contains( var )) &&
    (var == param) )", I get the following exception:
    com.techtrader.modules.jdo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=SELECT
    t0.JDOIDX, t0.JDOCLASSX, t0.JDOLOCKX FROM TESTCLASSX t0 WHERE variable =
    'value'] Line 1: Incorrect syntax near '*'. Severity 15, State 1, <rest of
    exception message omitted>
    at
    com.techtrader.modules.jdo.impl.jdbc.runtime.JDBCFieldData.load(JDBCFieldDat
    a.java:127)
    at
    com.techtrader.modules.jdo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuer
    y.java:33)
    at
    com.techtrader.modules.jdo.query.QueryImpl.executeWithMap(QueryImpl.java:330
    at
    com.techtrader.modules.jdo.query.QueryImpl.executeWithArray(QueryImpl.java:3
    93)
    Again, the generated SQL looks like:
    SELECT
    t0.JDOIDX,
    t0.JDOCLASSX,
    t0.JDOLOCKX
    FROM
    TESTCLASSX t0
    WHERE
    variable = 'value'
    We are using multiple queries for now and aggregating the results by hand,
    so this issue isn't blocking us.
    Regards,
    Sasha Haghani.
    "David Ezzio" <[email protected]> wrote in message
    news:[email protected]...
    Hi Sasha,
    One thing that appears "unusual", if you will, about your queries
    is that you are using a parameter in the contains() method rather
    than a variable. The spec mentions a different usage pattern along
    the following lines: "collection.contains(string) && string ==
    strParam" where "strParam" is declared as the parameter, and
    "string" is declared as a variable. You may have already tried this
    as a variation. Your usage appears permitted as far as the spec
    goes, but may not have been tested for Kodo.
    David Ezzio
    Sasha Haghani wrote:
    Hi Patrick,
    I tried your workaround and the following exception was thrown:
    javax.jdo.JDOUserException: The given filter/ordering String "( (
    (_collection1.isEmpty() == false) && (_collection1.contains( string )) )
    ||
    ( (_collection2.isEmpty() == false) && (_collection2.contains(
    string )) ) )" is not valid. Make sure all parentheses are properlymatched
    and that the filter uses proper Java syntax.
    at
    com.techtrader.modules.jdo.query.QueryImpl.getExpression(QueryImpl.java:371)
    at
    com.techtrader.modules.jdo.impl.jdbc.runtime.JDBCQuery.getExpression(JDBCQue
    ry.java:49)
    at
    com.techtrader.modules.jdo.query.QueryImpl.executeWithMap(QueryImpl.java:312
    at
    com.techtrader.modules.jdo.query.QueryImpl.executeWithArray(QueryImpl.java:3
    93)
    I tried three variations on the parentheses used in the filterexpression.
    All yielded the same exception. I couldn't find any glaring errors or
    omissions in the query. The string parameter is also properly declared.Is
    this possibly another bug?
    I'm executing multiple individual queries to acheive my goal for thetime
    being. Let me know if I'm doing anything wrong or if these are bugs,let me
    know when they are fixed. Thanks much.
    Regards,
    Sasha Haghani.
    "Patrick Linskey" <[email protected]> wrote in message
    news:[email protected]...
    Sasha,
    This sounds like a bug. I will enter it into our database and get back
    to you later.
    Meanwhile, you may be able to work around it using something like
    query.setFilter (
    "(_collection1.isEmpty () == false && _collection1.contains(string))"
    + " || (_collection2.isEmpty () == false &&
    _collection2.contains
    (string))" );
    -Patrick Linskey

  • How to sum strings?

    Hi,
    I am doing an XSLT transformation in BPEL. I have a situation where I have a collection with strings that I need to concat into one target field. The structure is like this:
    <qwerty>
        <animal>cat</animal>
        <animal>dog</animal>
        <animal>mouse</animal>
    </qwerty>I need this in the target: catdogmouse
    How do I do this?
    Regards Pete

    OK I got it working.
    <xsl:variable name="f_191_1_dummy">
      <xsl:for-each select="/tns1:hentNesteIndberetningResponse/tns1:hentNesteIndberetningReturn/tns1:Report/ns8:FertilizerAccountStructure/ns8:ConsumptionNitrogenStructure/ns8:OrganicFertilizerExceptManureStructure/ns8:FertilizerQuantitiesIncludedInAccountStructure/ns8:FertilizerQuantityCollection/ns8:FertilizerQuantityStructure/ns8:UnclassifiedFertilizer[../ns8:UnclassifiedFertilizer != '']">
        <xsl:value-of select="concat(normalize-space(./text()),' ')"/>
      </xsl:for-each>
    </xsl:variable>
    <ns0:F_191_1>
       <xsl:value-of select="substring($f_191_1_dummy,1,255)"/>
    </ns0:F_191_1>It works but please let me know if there is a better solution.
    Regards Pete

Maybe you are looking for

  • Is there a way to get voice messages to play through a stereo?

    I have a car stereo that I just plug my 5s right into. It's great for Spotify and podcasts and whatnot, but horrible for messaging. We'd been using Voxer for years for voice messaging, but it refused to play the messages through the stereo, so you'd

  • In Adobe Reader 9.0: How to print longer edited fields of a form ?

    I've filled a PDF form. When I filled more characters in a field, a "+" (plus) sign appeared at the bottom of the field, but the characters are there ! When I print the filled form, the full text of this field IS NOT PRINTED. Instead, a partial text

  • Apache proxypass and crossdomain.xml not working

    Hi everyone, I have the following problem. I have set up jboss on a Linux server connecting to local port 8080 (localhost:8080). I have opened the application on port 80 with Apache ( www.myDomain.com) and set up a virtual host that proxies this conn

  • Network Manager get ip but no connection to the internet

    Hi guys, I'm new to Arch, and first of all I must say that I think I'm going to love it :-) Never seen a package manager so fast to install a lot of packages! And it's kinda cool to have everything under control. But here is a problem I don't have un

  • Help I've just lost 8 years worth of iCal data

    I've just lost 8 years worth of iCal data. Does Apple still have the  data? My HD died. My Mac mini will not support the new "Cloud" portal. Does anyone have any ideas how I can retrieve my data from Apple? Thanks