Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPA @Table without table name: StringIndexOutOfBoundsException #2109

Closed
cdalexndr opened this issue Feb 23, 2017 · 4 comments
Closed

JPA @Table without table name: StringIndexOutOfBoundsException #2109

cdalexndr opened this issue Feb 23, 2017 · 4 comments

Comments

@cdalexndr
Copy link

@table may be used only do declare a unique constraint, ex:
@Table(uniqueConstraints = @UniqueConstraint(columnNames = {"shop_id", "url"}))
In this condition, NativeSQLSerializer.handleJoinTarget(JoinExpression) doesn't check if name is present, and results in StringIndexOutOfBoundsException.

Call Stack:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0

	at java.lang.String.charAt(String.java:658)
	at com.querydsl.sql.SQLTemplates.requiresQuotes(SQLTemplates.java:823)
	at com.querydsl.sql.SQLTemplates.quoteIdentifier(SQLTemplates.java:813)
	at com.querydsl.sql.SQLSerializer.appendTableName(SQLSerializer.java:108)
	at com.querydsl.jpa.NativeSQLSerializer.handleJoinTarget(NativeSQLSerializer.java:83)
	at com.querydsl.sql.SQLSerializer.serializeSources(SQLSerializer.java:656)
	at com.querydsl.sql.SQLSerializer.serializeForQuery(SQLSerializer.java:348)
	at com.querydsl.sql.SQLTemplates.serialize(SQLTemplates.java:844)
	at com.querydsl.sql.SQLSerializer.serialize(SQLSerializer.java:221)
	at com.querydsl.jpa.NativeSQLSerializer.serialize(NativeSQLSerializer.java:181)
	at com.querydsl.sql.ProjectableSQLQuery.serialize(ProjectableSQLQuery.java:490)
	at com.querydsl.jpa.sql.AbstractJPASQLQuery.createQuery(AbstractJPASQLQuery.java:98)
	at com.querydsl.jpa.sql.AbstractJPASQLQuery.createQuery(AbstractJPASQLQuery.java:94)
	at com.querydsl.jpa.sql.AbstractJPASQLQuery.fetchOne(AbstractJPASQLQuery.java:296)
@cdalexndr
Copy link
Author

Using QueryDSL version 4.1.4

@MitchelNijdam-Rockstars

3 years and still present in version 4.3.1 when using @Table without a name parameter

java.lang.StringIndexOutOfBoundsException: String index out of range: 0

	at java.lang.String.charAt(String.java:658)
	at com.querydsl.sql.SQLTemplates.requiresQuotes(SQLTemplates.java:823)
	at com.querydsl.sql.SQLTemplates.quoteIdentifier(SQLTemplates.java:813)
	at com.querydsl.sql.SQLSerializer.appendTableName(SQLSerializer.java:108)
	at com.querydsl.jpa.NativeSQLSerializer.handleJoinTarget(NativeSQLSerializer.java:83)
	at com.querydsl.sql.SQLSerializer.serializeSources(SQLSerializer.java:656)
	at com.querydsl.sql.SQLSerializer.serializeForQuery(SQLSerializer.java:348)
	at com.querydsl.sql.SQLTemplates.serialize(SQLTemplates.java:844)
	at com.querydsl.sql.SQLSerializer.serialize(SQLSerializer.java:221)
	at com.querydsl.jpa.NativeSQLSerializer.serialize(NativeSQLSerializer.java:181)
	at com.querydsl.sql.ProjectableSQLQuery.serialize(ProjectableSQLQuery.java:490)
	at com.querydsl.jpa.sql.AbstractJPASQLQuery.createQuery(AbstractJPASQLQuery.java:98)
	at com.querydsl.jpa.sql.AbstractJPASQLQuery.createQuery(AbstractJPASQLQuery.java:94)
	at com.querydsl.jpa.sql.AbstractJPASQLQuery.fetchOne(AbstractJPASQLQuery.java:296)

@cdalexndr
Copy link
Author

querydsl died in the meantime and was recently ressurected... I've moved to JOOQ.

@stale
Copy link

stale bot commented Jun 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 3, 2021
@stale stale bot closed this as completed Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants