-
Notifications
You must be signed in to change notification settings - Fork 57
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
Feature: create collections on startup #125
Comments
Hi @lotabout, are you sure that you have done nothing but It uses |
@mpv1989 Sorry that my report is partly true. It is not @Query("FOR v IN customers"
+ " SORT RAND()"
+ " LIMIT @count"
+ " RETURN v")
Set<Customer> findRandom(@Param("count") int count); I also confirmed that other custom queries will fail too. Are there any difference between custom query and |
Ok, now it makes sense for me.
As a workaround - and also as a better practice - you should use the placeholder @Query("FOR v IN #collection"
+ " SORT RAND()"
+ " LIMIT @count"
+ " RETURN v")
Set<Customer> findRandom(@Param("count") int count); But you are right, the collection should be created earlier, so that this problem can not be occur. |
@mpv1989 Thanks! Confirmed the Besides, extended queries won't create collections automatically neither. Any workarounds? public interface CharacterRepository extends ArangoRepository<Character, String> {
Optional<Character> findByNameAndSurname(String name, String surname);
// ...
} |
I also faced same issue with derived query. init {
someRepositoryA.findById("id")
someRepositoryB.findById("id")
} I believe that there must be better solution. |
I use |
So does it has some better solution to create collection automitically? |
using Spring I have a configuration like this (including spring-data-commons): @Configuration
class ArangoDatabaseInit implements InitializingBean {
@Autowired
private ArangoOperations client;
@Override
public void afterPropertiesSet() {
AnnotatedTypeScanner scanner = new AnnotatedTypeScanner(false, Document.class, Edge.class);
scanner.findTypes("your.base.package").forEach(client::collection);
}
} |
Currently the collections will be created when
repository.save()
is called if not already existed. Exceptions will be thrown if queries(e.g.repository.findAll()
) were called beforesave
because the tables do not exist.I was expecting the tables are created on spring startup so that
findAll()
will return empty collections, like what hibernate does.If I missed something in configuration, please tell.
The text was updated successfully, but these errors were encountered: