Spring & MongoDB full text search dependency error - java

I'm new to spring framework and I've generated a project with JHipster online using MongoDB as database. However I'm trying to setup text search for my MongoDB collection but when importing TextCriteria my code fails at compile time with the following error:
package org.springframework.data.mongodb.core.query.text does not exist
This is the code for my UserSearchRepository
// package path hidden
import ....User;
import org.springframework.data.mongodb.core.query.text.TextCriteria;
import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List;
* Spring Data MongoDB repository for the User entity.
public interface UserSearchRepository extends MongoRepository<User, String> {
List<User> search(TextCriteria textCriteria);
And this is the code for my search controller
public List<User> search(#PathVariable String query) {
TextCriteria textCriteria = TextCriteria.forDefaultLanguage();
return userSearchRepository.search(textCriteria);


findAll() method doesn't work when forceQuote is true in spring-data-cassandra

I'm using spring-data-cassandra in my spring boot project.
I use (forceQuote = true) because I have tables with uppercase letters.
When I tried to execute findById() method, it worked without any problem, but findAll() method threw an exception. I tried to debug the application and I found that spring-data-cassandra adds extra quotes to the table name while executing the query. So, the table name becomes ""MyTable"".
The exception is given string ["MyTable"] is not a valid quoted or unquoted identifier.
Is that a bug in spring-data-cassandra?
import lombok.Data;
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
import org.springframework.data.cassandra.core.mapping.Table;
#Table(value = "MyTable", forceQuote = true)
public class MyTable {
private Integer key;
//some attributes.
import org.springframework.data.cassandra.repository.CassandraRepository;
public interface MyTableRepository extends CassandraRepository<MyTable, Integer> {

Spring boot static where clause with JPA repositories

I'm working on a RESTful Spring Boot project that fetches data from mysql DB.
I want to print just all categories that have active field equal to 1
and I want to apply that for all method in CategoryRepository Class : findAll,findByParentId ..etc.
package com.userService.repositories;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import com.userService.entities.Category;
public interface CategoryRepo extends JpaRepository<Category, Integer> {
#Query("where active =1")
public List<Category> findByParentId(int id);
I tried to use query method but it doesn't work and gave me an excpetion
If you are using Hibernate as your persistence provider, you can take advantage of #Where clause on the entity level:
#Where(clause = "active =1")
public class Category{
This will be applied to all queries that go through the persistence provider.
it could be helpful to you if you are using the query method you should specify
select alias_name from Category c where condition
from Category where condition
directly by using method
findByActive(int id);
public interface CategoryRepo extends JpaRepository<Category, Integer> {
#Query("select c from Category c where c.active =1")
public List<Category> findByParentId(int id);
#Query annotation allows to execute native queries. So, I think, you should specify the complete sql as follows
#Query("select c from Category c where c.active =1")

Inject query ID automatically with mybatis

I want to inject query ID as a comment in SQL statement automatically to explain heavy queries.
If there is a mapper class like this:
package com.example.mapper;
import com.example.domain.Blog;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface BlogMapper {
#Select("SELECT * FROM blog WHERE id=#{id}")
List<Blog> findById(String id);
I want to send a query like
/* BlogMapper.findById */SELECT * FROM blog WHERE id=5

How Do I get the DataBase Data using Hibernate

Here's my code:
import model.Usuario;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
public class HibernateMain {
public static void main(String[] args) {
Configuration configuration=new Configuration();
ServiceRegistry sr= new ServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
SessionFactory sf=configuration.buildSessionFactory(sr);
Usuario user1=new Usuario();
Session ss=sf.openSession();
//saving objects to session
I want to verify if user1 is in my DB, how do I do it?
I've already made the hibernate.cfg.xml, and the class Usuario is an entity of one of my tables in my DB(I'm using Postgres and Eclipse IDE btw)
There are many was to retrieve data from database, its all depends upon the situation we need to use
If you want to retrieve the data's alone from the datatabase you can simply use
get(), load() method which retrieve the data from database and store it in the pojo classes , so whenever you need you can use it.
Parent parent = (Parent)session.load(Parent.class, serializableId);\\serializableId will the reference key
If you want to retriev the data based on some defined conditions you can use HQL query based retrieval concept
Query query = session.createQuery("from Parent as a where a.fName='Raj'");
If you want to retrieve a data from data , that continos based on dynamic means you can go ahead with HibernateCriteria
Criteria criteria = session.createCriteria(User.class);
See also..
Precedure to retrieve data from database

Play Framework 2.1.0 - Using Ebean to query existing database tables

I am having trouble with returning data from a existing database table (SQL Server 2008 R2). I can successfully authenticate and connect to the database, I have a model created that I attempted to map to a particular table, then as a test tried to return a row count, the row count always returns 0. I think perhaps I do not understand how Play/Ebean database connectivity works. At present I have the below:
Model - Data.java:
package models;
import javax.persistence.*;
import play.db.ebean.*;
public class Data extends Model {
private static final long serialVersionUID = 1L;
public int someKey;
public String someCol;
public static Finder<Integer,Data> find = new Finder<Integer,Data>( Integer.class, Data.class );
Controller - Index.java
package controllers;
import java.util.*;
import models.Data;
import play.mvc.*;
public class Index extends Controller {
static int rowCount = Data.find.getMaxRows();
public static Result index() {
Result res = ok(rowCount);
return res;
Application.conf (Relevant snippets):
I don't profess to understand how Evolutions work, but I do database development work separately in SQL, i.e. DDL and schema creation/modifying.
Any help would be greatly appreciated.
The thing you want to do is done by findRowCount() which returns the number of the rows your query affect. Basically a COUNT(*).
getMaxRows() is the equivalent to setMaxRows(int) which is a limitation for the number of rows returned by your query (e.g. LIMIT in MySQL).