Comments (12)
I fixed it, a dumb typo as usual. Thanks again for the help.
from blaze-persistence.
You're probably just missing an annotation. You have to replace your @EnableRepositories
annotation with @EnableBlazeRepositories
or if you want to work with both the Spring Data JPA repositories and Blaze-Persistence repositories, then you have to split your repositories into different packages and apply the basePackage
setting respectively. Also see https://persistence.blazebit.com/documentation/1.6/entity-view/manual/en_US/index.html#spring-data-setup
from blaze-persistence.
@beikov thanks, I've added the annotation and still don't see much difference. It seems to me that Blaze Persistence doesn't extend a typical JpaRepository, is that correct? I'd have to define another EntityView and EntityViewSpecification for that EntityView, then specify this under basePackages and use it separately?
from blaze-persistence.
Trying to build a view in kotlin...
@EntityView(CustomEntity::class)
interface CustomView {
@get:IdMapping
val id: UUID
}
seems to have issues:
Caused by: java.lang.IllegalArgumentException: Unknown managed type 'com.company.example.model.view.CustomView'
at com.blazebit.persistence.impl.EntityMetamodelImpl.getEntry(EntityMetamodelImpl.java:691)
at com.blazebit.persistence.impl.EntityMetamodelImpl.getManagedType(EntityMetamodelImpl.java:671)
at com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactory.getRepositoryBaseClass(BlazePersistenceRepositoryFactory.java:257)
at com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactory.lambda$getRepositoryInformation$2(BlazePersistenceRepositoryFactory.java:523)
at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330)
at com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactory.getRepositoryInformation(BlazePersistenceRepositoryFactory.java:521)
at com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactory.getRepository(BlazePersistenceRepositoryFactory.java:425)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:279)
at org.springframework.data.util.Lazy.getNullable(Lazy.java:245)
at org.springframework.data.util.Lazy.get(Lazy.java:114)
Sorry to be a pain, suggestions welcome though. Thanks for any reply.
from blaze-persistence.
You can try playing around with one of the quickstarts to figure out what you might be missing: https://github.com/Blazebit/blaze-persistence#quickstart
The error you just posted looks to me as if you were trying to setup a JpaRepository
with entity views. If you want some convenience methods, you can use the EntityViewRepository
interface, but note that if you want to implement JpaRepository
, you still have to pass the entity type as type variable when implementing the interface.
from blaze-persistence.
I used the quickstart to generate a project, then used that template to create a kotlin project with my setup to see if I could reproduce the issue.
This example project showcases the issue:
Caused by: java.lang.IllegalArgumentException: Unknown managed type 'com.example.demo.view.CatSimpleView'
at com.blazebit.persistence.impl.EntityMetamodelImpl.getEntry(EntityMetamodelImpl.java:691) ~[blaze-persistence-core-impl-jakarta-1.6.9.jar:1.6.9]
I don't know if its because of the kotlin code, or because we also have jpa repositories enabled alongside in separate packages or what's going on.
Make sure to run ./build_db_container.sh
to start the db (docker required)
from blaze-persistence.
From a quick look at the project, you should remove the bean for EntityViewConfiguration
in RepoConfig
i.e.
@Bean
fun entityViewConfiguration(): EntityViewConfiguration = EntityViews.createDefaultConfiguration()
from blaze-persistence.
@beikov this is required for creating the entityViewManager as shown in the instructions you linked.
Is the entity view manager not required to get the EntityView(s) working?
Removing this and the dependent bean entityViewManager (shown in the instructions) yields:
Field evm in com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactoryBean required a bean of type 'com.blazebit.persistence.view.EntityViewManager' that could not be found.
from blaze-persistence.
The @EnableEntityViews
annotation takes care of producing the EntityViewConfiguration
bean. See https://persistence.blazebit.com/documentation/1.6/entity-view/manual/en_US/index.html#anchor-environment-spring
from blaze-persistence.
@beikov thank you! That fixed it in the demo but somehow not in my main app.. sorry that's a bit confusing, the IDE thinks that one wasn't defined. Curious why autoconfig doesn't setup the other beans by default via @ConditionalOnMissingBean annotation/autoconfig. This would simplify setup, andwould be a non-breaking change.
Also default bean scope is singleton, so I don't believe that is necessary.
Thank you very much for your timely replies :)
from blaze-persistence.
It just never occurred to me that we could use conditional beans. Would be great if you could contribute that 😀
from blaze-persistence.
Definitely might.. if I can get it working and used in production I'll have a vested interest in keeping this working and easy to use. Now the demo isn't useful in reproducing my issue so I'll have to bang my head on the wall a while longer. Thanks again for help so far @beikov
from blaze-persistence.
Related Issues (20)
- Support determining if PagedList has next page
- Allow specifying defaults first/last for GraphQL pagination queries
- Don't create input types for non-updatable/creatable entity views
- The generated SQL statement order by is incorrect HOT 1
- Re-using ObjectMapper from spring-boot for EntityViewAwareMappingJackson2HttpMessageConverter leads to issues HOT 3
- Allow multiple named subqueries for @MappingSubquery
- Optimization of logging in the AnnotationUtils Utility Class HOT 1
- FR: Support field-EntityView deserializatin for DTOs which are non-entity views
- Expose EntityViewAwareMappingJackson2HttpMessageConverter as a Bean to support re-usage for http-clients
- Property naming strategy for Jackson integration does not work HOT 3
- How to ignore a certain `Getter` in EntityView? HOT 1
- Query DSL with blaze-persistence is generating an extra joining HOT 6
- SubviewAttributeFlusher always cascade deletes
- Exception thrown when using LocalDate in an EntityView being fetched using the Multiset strategy
- Startup error with Spring Boot 3.3.0 and Blaze Persistence Repositories HOT 5
- "No viable alternative at input" error near 'entity_function'
- Exception thrown when using subQuery + pagedList
- Fetching of MULTISET attribute not working HOT 3
- Question. Can i use fields mapped as @Convert in multiset mode? HOT 1
- Cannot invoke "EntityType.getName()" because the return value of "JoinNode.getTreatType()" is null HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blaze-persistence.