java.lang.StringIndexOutOfBoundsException: String index out of range: -1

Hibernate JIRA | Adrian Minciuna | 1 decade ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rp . Or join the community to write better ones.
  1. 0

    Bug: i have 2 classes DACPerson and DACDepartment DACPerson has an inner object manager with DACPerson , and an object department with type DACDepartment. Thus, has 2 relations <many-to-one> I need an hql like this 1) using left join select als.name, als0.name, als1.name, als2.name from DACPerson as als left join als.manager as als0 left join als.manager.manager as als1 left join als.manager.department as als2 where als.pkid=als.hcod In this case hibernate generate a wrong SQL : select tstdacpe0_.PKID as x0_0_,tstdacde3_.NAME as x1_0_, tstdacpe2_.NAME as x2_0_, tstdacpe0_.NAME as x3_0_,tstdacpe1_.NAME as x4_0_ from PERSON2 tstdacpe0_ left outer join PERSON2 tstdacpe1_ on tstdacpe0_.MGR_ID=tstdacpe1_.PKID left outer join PERSON2 tstdacpe2_ on tstdacpe1_.MGR_ID=tstdacpe2_.PKID left outer join DEPT tstdacde3_ on tstdacpe1_.Dept_id=tstdacde3_.PKID where and and ((tstdacpe0_.PKID=tstdacpe0_.HCOD )) java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Incorrect syntax near the keyword 'and'. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)..... ------------------------------------------- Obs. if i try a HQL,a little bit simple ex: select als.name, als0.name, als1.name from DACPerson as als left join als.manager as als0 left join als.manager.department as als1 where als.pkid=als.hcod i get following error FINE: net.sf.hibernate.hql.QueryTranslator.compile() - unexpected query compilation problem java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1480) at java.lang.String.substring(String.java:1447) at net.sf.hibernate.sql.QuerySelect.toQueryString(QuerySelect.java:109) at net.sf.hibernate.hql.QueryTranslator.renderSQL(QueryTranslator.java:515) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:151) --------------------------------------------------------- 3) If i modify hql like this : select als.name, als0.name, als1.name, als2.name from DACPerson as als left join als.manager as als0 left join als0.manager as als1 left join als0.department as als2 where als.pkid=als.hcod and IT'S WORK fine --------------------------------------------------- Obs: i tested also on Hibern8 IDE

    Hibernate JIRA | 1 decade ago | Adrian Minciuna
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
  2. 0

    Bug: i have 2 classes DACPerson and DACDepartment DACPerson has an inner object manager with DACPerson , and an object department with type DACDepartment. Thus, has 2 relations <many-to-one> I need an hql like this 1) using left join select als.name, als0.name, als1.name, als2.name from DACPerson as als left join als.manager as als0 left join als.manager.manager as als1 left join als.manager.department as als2 where als.pkid=als.hcod In this case hibernate generate a wrong SQL : select tstdacpe0_.PKID as x0_0_,tstdacde3_.NAME as x1_0_, tstdacpe2_.NAME as x2_0_, tstdacpe0_.NAME as x3_0_,tstdacpe1_.NAME as x4_0_ from PERSON2 tstdacpe0_ left outer join PERSON2 tstdacpe1_ on tstdacpe0_.MGR_ID=tstdacpe1_.PKID left outer join PERSON2 tstdacpe2_ on tstdacpe1_.MGR_ID=tstdacpe2_.PKID left outer join DEPT tstdacde3_ on tstdacpe1_.Dept_id=tstdacde3_.PKID where and and ((tstdacpe0_.PKID=tstdacpe0_.HCOD )) java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Incorrect syntax near the keyword 'and'. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)..... ------------------------------------------- Obs. if i try a HQL,a little bit simple ex: select als.name, als0.name, als1.name from DACPerson as als left join als.manager as als0 left join als.manager.department as als1 where als.pkid=als.hcod i get following error FINE: net.sf.hibernate.hql.QueryTranslator.compile() - unexpected query compilation problem java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1480) at java.lang.String.substring(String.java:1447) at net.sf.hibernate.sql.QuerySelect.toQueryString(QuerySelect.java:109) at net.sf.hibernate.hql.QueryTranslator.renderSQL(QueryTranslator.java:515) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:151) --------------------------------------------------------- 3) If i modify hql like this : select als.name, als0.name, als1.name, als2.name from DACPerson as als left join als.manager as als0 left join als0.manager as als1 left join als0.department as als2 where als.pkid=als.hcod and IT'S WORK fine --------------------------------------------------- Obs: i tested also on Hibern8 IDE

    Hibernate JIRA | 1 decade ago | Adrian Minciuna
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
  3. 0
    samebug tip
    You need to make sure that capitalisation of the case for the plugin in the properties file is exactly: "AllocinePlugin" and not "allocineplugin"
    via GitHub by Omertron
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    JWSDP RegistryServer error

    Oracle Community | 1 decade ago | 843834
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
  6. 0

    How to fix the ERROR [[jsp]] Servlet.service() for servlet jsp threw exception?

    Stack Overflow | 2 years ago | balaguru
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1

  1. Pilleo 1 times, last 3 days ago
  2. Andreas Häber 2 times, last 2 weeks ago
  3. QrCeric 1 times, last 3 weeks ago
  4. filpgame 2 times, last 2 months ago
  5. gamebusterz 1 times, last 2 months ago
23 more registered users
59 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.StringIndexOutOfBoundsException

    String index out of range: -1

    at java.lang.String.substring()
  2. Java RT
    String.substring
    1. java.lang.String.substring(String.java:1480)
    2. java.lang.String.substring(String.java:1447)
    2 frames
  3. net.sf.hibernate
    QueryTranslator.compile
    1. net.sf.hibernate.sql.QuerySelect.toQueryString(QuerySelect.java:109)
    2. net.sf.hibernate.hql.QueryTranslator.renderSQL(QueryTranslator.java:515)
    3. net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:151)
    3 frames