Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Transient field breaks application context #54

Closed
kirill-kravchenko opened this issue Jan 17, 2022 · 2 comments
Closed

@Transient field breaks application context #54

kirill-kravchenko opened this issue Jan 17, 2022 · 2 comments

Comments

@kirill-kravchenko
Copy link

Hi!
I'm using infobip-spring-data-jdbc-querydsl-boot-starter 6.2.1 version with querydsl 5.0.0
And when I use @Transient like in the following block:

@Table("entity")
@Data
@Builder
@RequiredArgsConstructor
public class Entity {

    @Id
    private final Long id;

    @Transient
    private final boolean isNew;
}

I get exception:

Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: java.lang.NullPointerException
	at com.querydsl.core.types.ConstructorExpression.getParameterTypes(ConstructorExpression.java:59)
	at com.querydsl.core.types.ConstructorExpression.<init>(ConstructorExpression.java:74)
	at com.querydsl.core.types.Projections.constructor(Projections.java:121)
	at com.infobip.spring.data.common.QuerydslExpressionFactory.getConstructorExpression(QuerydslExpressionFactory.java:54)
	at com.infobip.spring.data.jdbc.QuerydslJdbcRepositoryFactory.getRepositoryFragments(QuerydslJdbcRepositoryFactory.java:73)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepositoryComposition(RepositoryFactorySupport.java:371)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:276)
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:323)
	at org.springframework.data.util.Lazy.getNullable(Lazy.java:230)
	at org.springframework.data.util.Lazy.get(Lazy.java:114)
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:329)
	at org.springframework.data.jdbc.repository.support.JdbcRepositoryFactoryBean.afterPropertiesSet(JdbcRepositoryFactoryBean.java:201)
	at com.infobip.spring.data.jdbc.QuerydslJdbcRepositoryFactoryBean.afterPropertiesSet(QuerydslJdbcRepositoryFactoryBean.java:161)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782)
	... 162 more

Looks like #18 problem.

@lpandzic
Copy link
Member

lpandzic commented Jan 28, 2022

Hello,
if I remember correctly, a constructor without @Transient field is required and it should be marked with @PersistenceConstructor.
For details check out related test classes.

@lpandzic
Copy link
Member

lpandzic commented Feb 10, 2022

I'm closing this one, please read the above reply and if it doesn't work or if you have any more question feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants