Hibernate Search:由另一个程序持有的锁:var / lucene / indexes / com.org.Recipe / write.lock

时间:2016-09-29 18:29:23

标签: java hibernate lucene hibernate-search

我正在使用hibernate search 5.5.4,同时向数据库添加新记录,发生此异常并且数据已成功插入数据库但未创建索引

发生异常org.apache.lucene.store.LockObtainFailedException:由另一个程序持有的锁:var / lucene / indexes / com.org.Recipe / write.lock

2 个答案:

答案 0 :(得分:0)

Ya解决了,问题是当我将session.save()更改为session.persist()时我试图将数据保持为import java.util.Scanner; public class Programming { /* * get the number of matching digits between the guess and the * answer, ignoring repeated matches */ public static int numberDigitsMatch(String guess, String answer) { int numberMatch = 0; int currentIndex = 0; int matchingIndex; while (currentIndex < guess.length()) { // check if the current digit of the guess is in the answer matchingIndex = answer.indexOf(guess.charAt(currentIndex)); if (matchingIndex < 0) { currentIndex++; } else { currentIndex++; numberMatch++; // remove the no longer relevant character from the answer answer = answer.substring(0, matchingIndex) + answer.substring(matchingIndex + 1); } } return numberMatch; } public static void main(String[] args) { Scanner in = new Scanner(System.in); // generate the winning number int lotteryNumber = (int) (Math.random() * 10000); String lotteryString = "" + lotteryNumber; System.out.println("The lottery number is " + lotteryString); // Prompt the user to enter a guess System.out.print("Enter your lottery pick (four digits): "); // get the user's guess int guessNumber = in.nextInt(); String guessString = "" + guessNumber; // NOTE: these guessDigit numbers are not necessary. I am leaving // them here so you can see how to pick out individual digits int guessDigit1 = guessNumber % 10; int guessDigit2 = (guessNumber / 10) % 10; int guessDigit3 = (guessNumber / 100) % 10; int guessDigit4 = (guessNumber / 1000) % 10; int lotteryDigit1 = lotteryNumber % 10; int lotteryDigit2 = (lotteryNumber / 10) % 10; int lotteryDigit3 = (lotteryNumber / 100) % 10; int lotteryDigit4 = (lotteryNumber / 1000) % 10; System.out.println("The lottery number is " + lotteryString); int numMatchingDigits = numberDigitsMatch(guessString, lotteryString); if (guessNumber == lotteryNumber) { System.out.println("Exact match: you win $10,000"); } else if (4 == numMatchingDigits) { System.out.println("Match all digits: you win $5,000"); } else if (3 == numMatchingDigits) { System.out.println("Match three digits: you win $2,000"); } else if (2 == numMatchingDigits) { System.out.println("Match two digits: you win $500"); } else if (1 == numMatchingDigits) { System.out.println("Match two digit: you win $500"); } else { System.out.println("Sorry, no match"); } } } 问题消失了,索引值只能在持久,更新,删除等时更新。

答案 1 :(得分:0)

字面意思是错误所说的:还有另一个进程仍在运行,它“拥有”索引上的锁。

这很可能是Hibernate Search的另一个实例;例如,如果您之前启动了应用程序,并且没有将其关闭,就会发生这种情况。