GitHub user Eccenux created a discussion: No constructors warning for HQL using 
DTO class constructor

### Apache NetBeans version

Apache NetBeans 30

### What happened

I keep getting a warning "No constructors can de found that match the argument 
types" for HQL with DTO class.

### Language / Project Type / NetBeans Component

Java Maven Web application project

### How to reproduce

Package structure (simplified):

- webapp (REST controllers)
  - api (interface, dto)
  - core (DAO, service)
    - api (interface, dto)
    - ent (entities)

in example-api:
```java
package com.example.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ResourceCategoryMini {
        private Long id;
        private Boolean active;
        private String label;
        private String description;
}
```

in example-core:
```java
package com.example.core.dao;

import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.example.domain.ResourceCategoryMini;

@Repository
public class ResourceCategoryDAO {
        @Autowired
        protected SessionFactory sessionFactory;

        /**
         * Returns a minimal resource category list.
         *
         * @return resource category list
         */
        public List<ResourceCategoryMini> listMini() {
                Session session = sessionFactory.getCurrentSession();

                var results = session.createQuery("""
                        select new com.example.domain.ResourceCategoryMini(
                                r.id,
                                r.active,
                                r.label,
                                r.description
                        )
                        from ResourceCategoryEntity r
                        order by id asc
                        """, ResourceCategoryMini.class)
                        .getResultList();

                return results;
        }
}
```

### Did this work correctly in an earlier version?

No

### Operating System

Windows 11 version 10.0 running on amd64; UTF-8; pl_PL (nb)

### JDK

Runtime: OpenJDK Runtime Environment 21.0.8+9-LTS

### Apache NetBeans packaging

Community provided installer

### Anything else

<img width="410" height="137" alt="Image" 
src="https://github.com/user-attachments/assets/91a30a92-2ce2-4a12-859f-eb7c85fb0f02";
 />

That error is always shown when using DTO class in HQL.

Oh, and the project is based on Spring MVC + Hibernate + HikariCP data-source 
if that matters.

### Are you willing to submit a pull request?

No

GitHub link: https://github.com/apache/netbeans/discussions/9552

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to