Skip to content

Parsing of query method names is inconsistent for attributes beginning with a single lower case character followed by an upper case character [DATACMNS-1570] #1996

@spring-projects-issues

Description

@spring-projects-issues

GitFlip opened DATACMNS-1570 and commented

My JPA Repository Method Query cannot parse a property name that comes after the OrderBy, but it can if it follows the findBy or findAllBy. The attribute in my entity that is giving me issues is zIndex

Entity Class

 

@Entity
 public class DisplayLayer 
 {
 @Id
 @Column(name="DISPLAY_LAYER_ID")
 private Long id;
 
 @ManyToOne(cascade = CascadeType.ALL)
 @JoinColumn(name="DISPLAY_CONTAINER_ID")
 private DisplayContainer displayContainer;
 
 @Column(name="NAME")
 private String name;
 
 @Column(name="Z_INDEX")
 private Long zIndex;
 
 @Column(name="DESCRIPTION")
 private String description;
// Getters & Setters
 }

 

Repository Class

 

public interface DisplayLayerRepository extends BaseRepository<DisplayLayer, Long>
 {
 // This one method query works just fine
 public List<DisplayLayer> findByZIndex(Long pZIndex);
 // These two throw the same error:
 // Unable to locate Attribute with the the given name [ZIndex]
 //
 // public List<DisplayLayer> findAllByOrderByZIndexAsc();
 // public List<DisplayLayer> findByDisplayContainerIdOrderByZIndexAsc(Long pDisplayLayerId);
 }

 

So in my first method query, when OrderBy is not used, it correctly parses it as [zIndex], but when it follows the OrderBy for some reason it capitalizes the z: [ZIndex].

What makes me think there might be a bug with the parser is that if I update zIndex to IndexZ in my entity and then change my query methods from OrderByZIndex to OrderByIndexZ everything works


Issue Links:

  • DATACMNS-1589 Decapitalization of property names in repository queries breaks for properties with single lowercase letter followed by an uppercase letter

  • DATACMNS-1304 PropertyPath is created wrong for property with uppercase letters at the end

Referenced from: pull request #402

Backported to: 2.1.11 (Lovelace SR11)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions