未找到存储过程 'auto_pk_for_table'
stored procedure 'auto_pk_for_table' not found
我不知道为什么会收到错误消息:
org.apache.cayenne.CayenneRuntimeException: [v.4.0.M5 Feb 24 2017 07:47:55] Commit Exception
[...]
Caused by: java.sql.SQLException: Procédure stockée 'auto_pk_for_table' introuvable.
[...]
我正在使用 Cayenne :
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-server</artifactId>
<version>4.0.M5</version>
</dependency>
和 sql 服务器的 JDTS:
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
连接正常:
avr. 10, 2017 2:36:30 PM org.apache.cayenne.datasource.DriverDataSource getConnection
INFOS: +++ Connecting: SUCCESS.
我正在尝试创建一个新用户(我从 bascis 开始!)所以我的代码是:
(我剪了一点,太长了:!)
public abstract class _UserInfo extends CayenneDataObject {
public static final String ADDRESS_PROPERTY = "address";
public void setAddress(String address) {
writeProperty(ADDRESS_PROPERTY, address);
}
public String getAddress() {
return (String)readProperty(ADDRESS_PROPERTY);
}
}
public class UserInfo extends _UserInfo implements Serializable {
private static final long serialVersionUID = 1L;
public String address;
public String getAdress() {
return address;
}
public void setAddress(String address) {
super.setAddress(address);
}
//I have the hashcode and equals too
}
然后,我使用 vaadin 创建了我的表单:
public class UserAddView extends CustomComponent implements View {
private static final long serialVersionUID = 1L;
private TextField address;
private Button save;
public static final String USERVIEW = "user";
public boolean checkValidation() {
if (!checkTextFieldValid(address))
return false;
return true;
}
public boolean checkTextFieldValid(TextField element) {
if (element == null || element.isEmpty()) {
Notification.show(
"You should register a " + element.getDescription(),
Type.WARNING_MESSAGE);
return false;
}
return true;
}
public UserAddView() {
VerticalLayout mainLayout = new VerticalLayout();
mainLayout.setSizeFull();
setCompositionRoot(mainLayout);
final VerticalLayout vlayout = new VerticalLayout();
address = new TextField("Address:");
address.setDescription("Address");
vlayout.addComponent(address);
save = new Button("Save");
vlayout.addComponent(save);
mainLayout.addComponent(new HeaderMenu());
mainLayout.addComponent(vlayout);
addListeners();
}
private void addListeners() {
save.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
if (checkValidation() == true) {
ServerRuntime cayenneRuntime = ServerRuntime.builder()
.addConfig("cayenne-myapplication.xml").build();
ObjectContext context = cayenneRuntime.newContext();
UserInfo user = context.newObject(UserInfo.class);
user.setAddress(address.getValue());
user.getObjectContext().commitChanges();
Notification.show(
"Has been saved, We will send you your password by email. Your user login is: "
+ email.getValue(), Type.TRAY_NOTIFICATION);
getUI().getNavigator().navigateTo(HomepageView.MAINVIEW);
}
}
});
}
@Override
public void enter(ViewChangeEvent event) {
// TODO Auto-generated method stub
}
}
编辑,添加信息:在我的用户对象中,我有一个用户标识(主键),在 cayenne 中我也将其写为主键,在 smallint 中。这个错误好像是link...https://cayenne.apache.org/docs/3.1/api/org/apache/cayenne/dba/sybase/SybasePkGenerator.html
插入新对象时出现错误。对于每个新对象,Cayenne 都需要生成一个主键值。有多种策略可以做到这一点。默认策略取决于您使用的数据库。对于 SQLServer(以及 Sybase,如您所见:)),该策略是使用特殊的存储过程。
要创建此存储过程(以及其他支持的 DB 对象),请转至 CayenneModeler,打开您的项目,然后 select "Tools > Generate Database Schema"。在 "SQL Options" 选项卡中,取消选中除 "Create Primary Key Support" 之外的所有复选框。您将在复选框下方的 window 中看到的 SQL 是您在 SQL 服务器上 运行 所需要的。从 Cayenne 建模器或 copy/paste 到您最喜欢的数据库管理工具。
还有一个不需要存储过程的替代方案——使用数据库自增功能。为此,您需要转到建模器中的每个 DbEntity,并在 "Pk Generation Strategy" 下拉列表中的 "Entity" 选项卡 select "Database-Generated" 下。这当然意味着您的 PK 列确实是数据库中的自动增量(这意味着您可能需要相应地调整您的数据库架构)。
我不知道为什么会收到错误消息:
org.apache.cayenne.CayenneRuntimeException: [v.4.0.M5 Feb 24 2017 07:47:55] Commit Exception
[...]
Caused by: java.sql.SQLException: Procédure stockée 'auto_pk_for_table' introuvable.
[...]
我正在使用 Cayenne :
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-server</artifactId>
<version>4.0.M5</version>
</dependency>
和 sql 服务器的 JDTS:
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
连接正常:
avr. 10, 2017 2:36:30 PM org.apache.cayenne.datasource.DriverDataSource getConnection
INFOS: +++ Connecting: SUCCESS.
我正在尝试创建一个新用户(我从 bascis 开始!)所以我的代码是: (我剪了一点,太长了:!)
public abstract class _UserInfo extends CayenneDataObject {
public static final String ADDRESS_PROPERTY = "address";
public void setAddress(String address) {
writeProperty(ADDRESS_PROPERTY, address);
}
public String getAddress() {
return (String)readProperty(ADDRESS_PROPERTY);
}
}
public class UserInfo extends _UserInfo implements Serializable {
private static final long serialVersionUID = 1L;
public String address;
public String getAdress() {
return address;
}
public void setAddress(String address) {
super.setAddress(address);
}
//I have the hashcode and equals too
}
然后,我使用 vaadin 创建了我的表单:
public class UserAddView extends CustomComponent implements View {
private static final long serialVersionUID = 1L;
private TextField address;
private Button save;
public static final String USERVIEW = "user";
public boolean checkValidation() {
if (!checkTextFieldValid(address))
return false;
return true;
}
public boolean checkTextFieldValid(TextField element) {
if (element == null || element.isEmpty()) {
Notification.show(
"You should register a " + element.getDescription(),
Type.WARNING_MESSAGE);
return false;
}
return true;
}
public UserAddView() {
VerticalLayout mainLayout = new VerticalLayout();
mainLayout.setSizeFull();
setCompositionRoot(mainLayout);
final VerticalLayout vlayout = new VerticalLayout();
address = new TextField("Address:");
address.setDescription("Address");
vlayout.addComponent(address);
save = new Button("Save");
vlayout.addComponent(save);
mainLayout.addComponent(new HeaderMenu());
mainLayout.addComponent(vlayout);
addListeners();
}
private void addListeners() {
save.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
if (checkValidation() == true) {
ServerRuntime cayenneRuntime = ServerRuntime.builder()
.addConfig("cayenne-myapplication.xml").build();
ObjectContext context = cayenneRuntime.newContext();
UserInfo user = context.newObject(UserInfo.class);
user.setAddress(address.getValue());
user.getObjectContext().commitChanges();
Notification.show(
"Has been saved, We will send you your password by email. Your user login is: "
+ email.getValue(), Type.TRAY_NOTIFICATION);
getUI().getNavigator().navigateTo(HomepageView.MAINVIEW);
}
}
});
}
@Override
public void enter(ViewChangeEvent event) {
// TODO Auto-generated method stub
}
}
编辑,添加信息:在我的用户对象中,我有一个用户标识(主键),在 cayenne 中我也将其写为主键,在 smallint 中。这个错误好像是link...https://cayenne.apache.org/docs/3.1/api/org/apache/cayenne/dba/sybase/SybasePkGenerator.html
插入新对象时出现错误。对于每个新对象,Cayenne 都需要生成一个主键值。有多种策略可以做到这一点。默认策略取决于您使用的数据库。对于 SQLServer(以及 Sybase,如您所见:)),该策略是使用特殊的存储过程。
要创建此存储过程(以及其他支持的 DB 对象),请转至 CayenneModeler,打开您的项目,然后 select "Tools > Generate Database Schema"。在 "SQL Options" 选项卡中,取消选中除 "Create Primary Key Support" 之外的所有复选框。您将在复选框下方的 window 中看到的 SQL 是您在 SQL 服务器上 运行 所需要的。从 Cayenne 建模器或 copy/paste 到您最喜欢的数据库管理工具。
还有一个不需要存储过程的替代方案——使用数据库自增功能。为此,您需要转到建模器中的每个 DbEntity,并在 "Pk Generation Strategy" 下拉列表中的 "Entity" 选项卡 select "Database-Generated" 下。这当然意味着您的 PK 列确实是数据库中的自动增量(这意味着您可能需要相应地调整您的数据库架构)。