我试图在两个数据库表之间建立多态关系。
database1:SaleReport database2:ThreadConnection
数据库1上的SaleReport下的
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index -1 out-of-bounds for length 764
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:440)
at javafx.graphics/javafx.scene.Parent.updateCachedBounds(Parent.java:1723)
at javafx.graphics/javafx.scene.Parent.recomputeBounds(Parent.java:1667)
at javafx.graphics/javafx.scene.Parent.doComputeGeomBounds(Parent.java:1520)
at javafx.graphics/javafx.scene.Parent.access$200(Parent.java:81)
at javafx.graphics/javafx.scene.Parent$1.doComputeGeomBounds(Parent.java:117)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.computeGeomBoundsImpl(ParentHelper.java:86)
at javafx.graphics/com.sun.javafx.scene.layout.RegionHelper.superComputeGeomBoundsImpl(RegionHelper.java:78)
at javafx.graphics/com.sun.javafx.scene.layout.RegionHelper.superComputeGeomBounds(RegionHelper.java:62)
at javafx.graphics/javafx.scene.layout.Region.doComputeGeomBounds(Region.java:3291)
at javafx.graphics/javafx.scene.layout.Region.access$300(Region.java:149)
at javafx.graphics/javafx.scene.layout.Region$1.doComputeGeomBounds(Region.java:170)
at javafx.graphics/com.sun.javafx.scene.layout.RegionHelper.computeGeomBoundsImpl(RegionHelper.java:89)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.computeGeomBounds(NodeHelper.java:117)
at javafx.graphics/javafx.scene.Node.updateGeomBounds(Node.java:3831)
at javafx.graphics/javafx.scene.Node.getGeomBounds(Node.java:3793)
at javafx.graphics/javafx.scene.Node.getLocalBounds(Node.java:3741)
at javafx.graphics/javafx.scene.Node.updateTxBounds(Node.java:3895)
at javafx.graphics/javafx.scene.Node.getTransformedBounds(Node.java:3687)
at javafx.graphics/javafx.scene.Node.updateBounds(Node.java:766)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1851)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2522)
at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:410)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:409)
at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:436)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:518)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:498)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:491)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:319)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175)
at java.base/java.lang.Thread.run(Thread.java:844)
数据库2上的ThreadConnection上的
public function relates(){
return $this->morphMany(ThreadConnection::class, 'relation');
}
但是当我试图获得像
这样的关系时public function relation(){
return $this->morphTo();
}
我还尝试将数据库连接定义到ThreadConnection
$这 - > setConnection( 'DATABASE2') - > morphTo();
但这也不起作用!
任何建议都是适当的
答案 0 :(得分:0)
如前所述,
阅读错误:
protected $connection = 'database2';
含义Laravel正在寻找模型ThreadConnection的database1连接(如果model指的是另一个应该明确设置的连接,则database1应该是默认连接)
添加ThreadConnection:
/*search name is clinic name
clinicsearch is the arrayelement which has the list of clinic name list from the table*/
public SearchAndSelectClinicA(SearchName:string){
this.ClinicSearch.sendKeys(SearchName);
this.SearchIcon.click(); //click on the icon to get the clinic names
this.SearchedClinic.count().then(function(count){
//get the count of elements which are there in the Searchedclinic element array
if(count>1){
this.SearchedClinic.each(function(rows){
/*Failed: Cannot read property 'SearchedClinic' of undefined
(Error gets displayed when it comes to above line.*/
rows.getText().then(function(value){
if(value.indexOf(SearchName)){
//Click the element if the statement is satisfied
rows.click();
}
});
});
}
});
}
将解决问题。