Miguel Guilherme
12/15/2020, 2:57 PMRobert Jaros
12/21/2020, 12:58 AMtvtan
12/22/2020, 11:22 AMdodalovic
12/29/2020, 11:01 PMCaused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'conversionServicePostProcessor' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Cannot register bean definition [Root bean: class [org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=conversionServicePostProcessor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]] for bean 'conversionServicePostProcessor': There is already [Root bean: class [org.springframework.security.config.annotation.web.reactive.WebFluxSecurityConfiguration]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=conversionServicePostProcessor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.class]] bound.
Anyone came across this? I'm using kotlin, reactive web, coroutines, functional routerRobert Jaros
01/04/2021, 12:43 AMorg.springframework.security.config.web.server.invoke
. Is this a known issue or just something on my side?Dmitry
01/05/2021, 1:41 PMspring-data-jpa
in my project.
In some of my entities I am defining associations as a lateinit
fields.
Like so:
@Entity
data class Example(...) {
...
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "anotherId", insertable = false, updatable = false)
lateinit var another: AnotherEntity
}
However, it seems like hibernate does not really play well latenit
field.
After I do repository.save(example)
, if I try to access another
field I get lateinit property has not been initialized
.
Did anyone encountered such problem before?Łukasz Bednarczyk
01/05/2021, 1:44 PMkqr
01/05/2021, 1:49 PMnfrankel
01/05/2021, 2:07 PMdata
classes are meant for value objects:
2 such objects are equals if all their properties are equals
which is not the case for database entities
i’d really avoid data classes to model entitieskqr
01/05/2021, 2:12 PMbjonnh
01/06/2021, 8:05 PMbjonnh
01/06/2021, 8:05 PMbjonnh
01/08/2021, 11:57 PMbjonnh
01/08/2021, 11:57 PMbjonnh
01/09/2021, 12:03 AMkqr
01/09/2021, 1:48 PMimport org.springframework.transaction.PlatformTransactionManager
import org.springframework.transaction.support.DefaultTransactionDefinition
import org.springframework.transaction.support.TransactionTemplate
import java.util.concurrent.ConcurrentHashMap
class DefaultTransactionManagerProvider {
companion object {
const val DEFAULT_MANAGER_NAME = "default"
private val managers = ConcurrentHashMap<String, PlatformTransactionManager>()
fun registerManager(platformTransactionManager: PlatformTransactionManager, name: String = DEFAULT_MANAGER_NAME) {
managers[name] = platformTransactionManager
}
fun get(name: String = DEFAULT_MANAGER_NAME): PlatformTransactionManager =
managers[name] ?: throw IllegalStateException("Transaction manager named [$name] not provided")
}
}
fun <R> transactional(
transactionManagerName: String = DefaultTransactionManagerProvider.DEFAULT_MANAGER_NAME,
transactionManager: PlatformTransactionManager = DefaultTransactionManagerProvider.get(transactionManagerName),
propagationBehaviour: Int = DefaultTransactionDefinition().propagationBehavior,
isolationLevel: Int = DefaultTransactionDefinition().isolationLevel,
timeout: Int = DefaultTransactionDefinition().timeout,
readOnly: Boolean = DefaultTransactionDefinition().isReadOnly,
name: String? = DefaultTransactionDefinition().name,
block: () -> R
): R {
val transactionTemplate = TransactionTemplate(transactionManager)
transactionTemplate.isolationLevel = isolationLevel
transactionTemplate.propagationBehavior = propagationBehaviour
transactionTemplate.timeout = timeout
transactionTemplate.isReadOnly = readOnly
name?.let { transactionTemplate.setName(it) }
val execute = transactionTemplate.execute {
block()
}
return execute!!
}
TheOnlyTails
01/15/2021, 10:28 PM@Entity
@Table
class Student(
@Id
@SequenceGenerator(name = "student_sequence", sequenceName = "student_sequence", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "student_sequence")
val id: Long,
val name: String,
val email: String,
val dateOfBirth: LocalDate,
val age: Int = LocalDate.now().year - dateOfBirth.year
)
I'm trying to access it in this class, and I think I'm supposed to leave out the id
so it can get filled in automatically, but it's not working. Here is where I try to create it:
@Configuration
class StudentConfig {
@Bean
fun commandLineRunner(repository: StudentRepository): CommandLineRunner {
return CommandLineRunner{
val theonlytails = Student(
"TheOnlyTails",
"<mailto:shacharzidon@gmail.com|shacharzidon@gmail.com>",
LocalDate.of(2000, Month.JANUARY, 1)
)
repository.save(theonlytails)
}
}
}
What is going on here?kqr
01/15/2021, 10:36 PMLong?
TheOnlyTails
01/15/2021, 11:00 PMTheOnlyTails
01/15/2021, 11:01 PMTheOnlyTails
01/15/2021, 11:03 PMTheOnlyTails
01/15/2021, 11:03 PMTheOnlyTails
01/16/2021, 11:01 AM@Entity
@Table
data class Student(
@Id
@SequenceGenerator(name = "student_sequence", sequenceName = "student_sequence", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "student_sequence")
var id: Long? = null,
val name: String,
val email: String,
val dateOfBirth: LocalDate,
val age: Int,
)
Since I have dateOfBirth
, I can just calculate the age from it, so I want to make it transient. Thing is, I am very new to Spring Boot and SQL, and have no idea how to do this. Googling did not help.
Thanks in advance!kqr
01/16/2021, 11:11 AMTheOnlyTails
01/16/2021, 11:12 AMkqr
01/16/2021, 11:20 AM@Entity
@Table
class Student(
@Id
@SequenceGenerator(name = "student_sequence", sequenceName = "student_sequence", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "student_sequence")
var id: Long? = null,
val name: String,
val email: String,
val dateOfBirth: LocalDate,
) {
@Transient
fun getAge(): Int = somemagic
}
kqr
01/16/2021, 11:20 AMTheOnlyTails
01/16/2021, 11:22 AMHamza GATTAL
01/17/2021, 7:56 AMKyooSik Lee
01/18/2021, 4:19 AMprivate fun makeFormData()
fun sendDataToServer() = <http://client.post|client.post>().body(makeFormData())
The function that uses private function sends a http request to another server.
Is there a way to capture this request and assert on body data?