jackwu982 / vite-quasar-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TODO

  • auditing
  • cors
  • csrf
  • exception
  • api result
  • dto to entity

auditing

class Customer {

  @CreatedBy
  private User user;

  @CreatedDate
  private Instant createdDate;

  // … further properties omitted
}

https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#auditing https://www.programmingmitra.com/2017/02/automatic-spring-data-jpa-auditing-saving-CreatedBy-createddate-lastmodifiedby-lastmodifieddate-automatically.html

cors with security

use global cors replace @CrossOrigin on Controller level

https://docs.spring.io/spring-security/site/docs/4.2.x/reference/html/cors.html

csrf

https://docs.spring.io/spring-security/site/docs/4.2.x/reference/html/csrf.html

security

JUnit 5 Jupiter

In JUnit 5 the package name has changed and the Assertions are at org.junit.jupiter.api.Assertions and Assumptions at org.junit.jupiter.api.Assumptions

So you have to add the following static import:

import static org.junit.jupiter.api.Assertions.*;

See also http://junit.org/junit5/docs/current/user-guide/#writing-tests-assertions

Exception

{
  "code": 405,
  "status": "fail",
  "data": "MethodNotAllowed",
  "message": "Request method 'GET' not supported"
}
{
  "timestamp": "2021-12-27T07:12:40.562+00:00",
  "status": 405,
  "error": "Method Not Allowed",
  "message": "Request method 'GET' not supported",
  "path": "/users/"
}

custom profile with gradle bootRun

 gradle bootRun  --args='--spring.profiles.active=test -sprot=9000'

Open-in-view

https://www.baeldung.com/hibernate-initialize-proxy-exception

Using Join Fetching
We can also use a JOIN FETCH directive in JPQL to fetch the associated collection on-demand:

SELECT u FROM User u JOIN FETCH u.roles

Or we can use the Hibernate Criteria API:

Criteria criteria = session.createCriteria(User.class);
criteria.setFetchMode("roles", FetchMode.EAGER);

About


Languages

Language:Java 98.3%Language:Shell 1.7%