Updated hibernate DDL policy and solved LazyInitializationException bug on User.toString()

This commit is contained in:
Claudio Maggioni 2020-02-26 14:41:11 +01:00
parent ad3e5271ac
commit 0cb1f1606a
4 changed files with 7 additions and 13 deletions

View file

@ -29,15 +29,15 @@ public abstract class Device {
/**
* The name for the category of this particular device (e.g 'dimmer'). Not stored in the
* database (thanks to 'transient') but set thanks to constructors
* database but set thanks to constructors
*/
private final transient String kind;
@Transient private final String kind;
/**
* The way this device behaves in the automation flow. Not stored in the database (thanks to
* 'transient') but set thanks to constructors
* The way this device behaves in the automation flow. Not stored in the database but set thanks
* to constructors
*/
private final transient FlowType flowType;
@Transient private final FlowType flowType;
public long getId() {
return id;
@ -66,6 +66,5 @@ public abstract class Device {
public Device(String kind, FlowType flowType) {
this.kind = kind;
this.flowType = flowType;
this.name = kind + " " + this.id;
}
}

View file

@ -15,8 +15,6 @@ public class JWTUserDetailsService implements UserDetailsService {
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User toReturn = repository.findByUsername(username);
System.out.println("malusa: " + username);
System.out.println(toReturn);
if (toReturn != null) {
return new org.springframework.security.core.userdetails.User(
toReturn.getUsername(), toReturn.getPassword(), Set.of());

View file

@ -86,9 +86,6 @@ public class User {
+ '\''
+ ", email='"
+ email
+ '\''
+ ", rooms="
+ rooms
+ '}';
+ "\'}";
}
}

View file

@ -6,7 +6,7 @@ spring.datasource.password=
# Hibernate properties
spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.jpa.properties.hibernate.format_sql=true