strelok
08/01/2017, 2:26 PMbean {
Routes(ref(), ref())
}
I mean I understand what this does. But just looks a bit WTF to me. Normal Java/Kotlin
@Configuration would look better and be more explicit in this case.sdeleuze
08/01/2017, 2:29 PMsdeleuze
08/01/2017, 2:33 PMsdeleuze
08/01/2017, 2:45 PMsdeleuze
08/01/2017, 2:46 PMstrelok
08/01/2017, 2:52 PMref<UserHandler>()
. It just jumped at me 🤔 when I saw it like that.sdeleuze
08/01/2017, 3:04 PMfitzoh
08/01/2017, 3:53 PM@ConditionalOnMissingBean
fitzoh
08/01/2017, 3:53 PM@ConditionalOnMissingBean(String::class)
@Bean
fun fallbackStringBean() : String? = null
lewis
08/02/2017, 10:07 AMCaused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [application.bla.Properties]: No corresponding Kotlin constructor found
at org.springframework.beans.BeanUtils$KotlinDelegate.instantiateClass(BeanUtils.java:742) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
I'm using the kotlin-spring plugin in my Gradle scriptlewis
08/02/2017, 10:36 AMsdeleuze
08/02/2017, 2:52 PMsdeleuze
08/02/2017, 2:54 PMziad
08/02/2017, 10:12 PM@Bean
fun init(dataSource: DataSource)
Intellij complains with a:
"Could not autowire. There is more than one bean of 'DataSource' type"
dataSource (DataSourceConfiguration.class)
dataSource (DataSourceConfiguration.class)
Can someone tell me what I'm doing wrong please? Or explain to me why intellij is complaining? I'm somewhat confused by the duplication. Also curiously this compiles and appears to be working correctly during runtime, intellij bug?ziad
08/02/2017, 10:13 PMtimp
08/02/2017, 10:18 PMtimp
08/02/2017, 10:24 PMziad
08/02/2017, 10:29 PMziad
08/02/2017, 10:29 PMshainegordon
08/03/2017, 10:28 PMClass<T> requiredType
as a parametershainegordon
08/03/2017, 10:28 PMshainegordon
08/03/2017, 10:28 PMval id = 123.toLong()
val externalSystemId = jdbcTemplate.queryForObject("select external_system_id from foo where id = ? limit 1 ", Long.class, id)
shainegordon
08/03/2017, 10:29 PMLong.class
is not validshainegordon
08/03/2017, 10:32 PMLong.javaClass
then the type of externalSystemId
is Long.Companion!
shainegordon
08/03/2017, 10:34 PMLong
shainegordon
08/03/2017, 10:34 PMLong?
strelok
08/03/2017, 11:57 PMLong::class.java
that's the standard way.strelok
08/04/2017, 12:02 AMinline fun <reified T> JdbcTemplate.queryForObject(sql: String, varargs args: Any) = this.queryForObject(sql, T::class.java, args)
and use it like this:
val result: Long = jdbcTemplate.queryForObject("select external_system_id from foo where id = ? limit 1 ", id)
// OR
val result = jdbcTemplate.queryForObject<Long>("select external_system_id from foo where id = ? limit 1 ", id)
shainegordon
08/04/2017, 8:33 AMpixelbumper
08/06/2017, 12:56 PM@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
abstract class Credential(
@ManyToOne
@JoinColumn
val account: Account
) {
@Id
val id = UUID.randomUUID()
@Column(name = "DTYPE", insertable = false, updatable = false)
val type: CredentialType
Preferably i would like the type field to be a val
but unfortunately the field needs to be somewhat initialized. What are my options for such a case?