Skip to content

Commit 2e79f2c

Browse files
committed
Dto Via Tuple
1 parent 51c933d commit 2e79f2c

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

HibernateSpringBootDtoTupleAndJpql/src/main/java/com/bookstore/MainApplication.java

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public ApplicationRunner init() {
3333
System.out.println("Author name: " + author.get("name")
3434
+ " | Age: " + author.get("age"));
3535
}
36+
37+
System.out.println("\n------------------");
38+
System.out.println(authors.get(0).get("name") instanceof String);
39+
System.out.println(authors.get(0).get("age") instanceof Integer);
3640
};
3741
}
3842
}

HibernateSpringBootDtoTupleAndJpql/src/main/java/com/bookstore/repository/AuthorRepository.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
public interface AuthorRepository extends JpaRepository<Author, Long> {
1313

1414
@Transactional(readOnly = true)
15-
@Query(value = "SELECT a.name AS name, a.age AS age FROM Author a")
15+
@Query(value = "SELECT a.id AS id, a.name AS name, a.age AS age FROM Author a")
1616
List<Tuple> fetchAuthors();
1717
}

HibernateSpringBootDtoTupleAndJpql/src/main/resources/application.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ spring.datasource.password=root
55
spring.jpa.hibernate.ddl-auto=create
66
spring.jpa.show-sql=true
77

8-
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
8+
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
99

1010
spring.datasource.initialization-mode=always
1111
spring.datasource.platform=mysql

0 commit comments

Comments
 (0)