Coder Social home page Coder Social logo

Comments (12)

thejeff77 avatar thejeff77 commented on June 21, 2024 1

I fixed it, a dumb typo as usual. Thanks again for the help.

from blaze-persistence.

beikov avatar beikov commented on June 21, 2024

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.

thejeff77 avatar thejeff77 commented on June 21, 2024

@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.

thejeff77 avatar thejeff77 commented on June 21, 2024

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.

beikov avatar beikov commented on June 21, 2024

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.

thejeff77 avatar thejeff77 commented on June 21, 2024

demo 4.zip

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.

beikov avatar beikov commented on June 21, 2024

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.

thejeff77 avatar thejeff77 commented on June 21, 2024

@beikov this is required for creating the entityViewManager as shown in the instructions you linked.

https://persistence.blazebit.com/documentation/1.6/entity-view/manual/en_US/index.html#spring-data-setup

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.

beikov avatar beikov commented on June 21, 2024

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.

thejeff77 avatar thejeff77 commented on June 21, 2024

@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.

beikov avatar beikov commented on June 21, 2024

It just never occurred to me that we could use conditional beans. Would be great if you could contribute that 😀

from blaze-persistence.

thejeff77 avatar thejeff77 commented on June 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.