我遇到了确定哪个约束触发 DataIntegrityViolationException 的问题。我有两个独特的限制:用户名和电子邮件,但我没有运气试图弄清楚。
我尝试获取根本原因异常,但收到此消息
Unique index or primary key violation: "UK_6DOTKOTT2KJSP8VW4D0M25FB7_INDEX_4 ON PUBLIC.USERS(EMAIL) VALUES ('copeland@yahoo.com', 21)"; SQL statement:
insert into users (id, created_at, updated_at, country, email, last_name, name, password, phone, sex, username) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [23505-193]
阅读错误我知道电子邮件约束会触发验证,但我想返回给用户,例如:
{type: ERROR, message: "The email already exist"}
我在其他帖子中读过,人们处理它,在异常中寻找约束名称(例如,users_unique_username_idx)并向用户显示正确的消息。但我无法获得那种类型的约束名称
也许我缺少一个配置。我在用:
Spring Boot 1.5.1.RELEASE, JPA, Hibernate and H2
我的应用程序属性
spring.jpa.generate-ddl=true
用户.类:
@Entity(name = "users")
public class User extends BaseEntity {
private static …Run Code Online (Sandbox Code Playgroud) (Nuxt 项目)我一直在寻找与在同一页面上显示未经身份验证和经过身份验证的内容相关的解决方案。
我有两种可能的解决方案,但它们有一些警告。
第一个,决定mounted用户是否可以看到经过身份验证的内容的方法,但我无法解决闪烁的内容问题,这是该方法的演示:
https://60f08a8293123d00e57c14e8--happy-minsky-1268c6.netlify。 app/
点击登录按钮并重新加载页面,您将看到闪烁的内容
我的第二种方法,它使用null避免未经身份验证和经过身份验证的内容,直到应用程序到达该mounted方法,此解决方案的问题是它对搜索引擎不友好,因为没有生成静态内容,请比较这两个链接:
从此解决方案生成: https : //gist.github.com/ltroya-as/fbbdce2b3dc30063e9c4ec7e93e3aba1#file-index-generated-file-html-L522
预期: https : //gist.github.com/ltroya-as/d37e3d0a89efebbfd66c2daf7700f50d#file-expected-generated-file-html-L523
有没有办法让第二个解决方案对搜索引擎更友好?我担心第二种解决方案会影响搜索引擎结果。
带有说明的存储库:https : //github.com/ltroya-as/nuxt-rehydration-example
- - 更新
我的项目配置为全静态模式
有没有一种方法可以通过使用应用内部的按钮将应用最小化到后台?
当您按退出选项时,某些应用程序会执行此操作。他们不会关闭,但会将应用程序置于后台...
我想用我的Ionic应用程序或科尔多瓦方式做到这一点。
我有一个类作为静态的一些属性,类是静态的,但我得到的错误是字段不是静态的.
我无法找到解决方案,我看到的示例看起来非常相似.视图保持器始终在适配器内部作为静态或公共静态
这是我的ArrayAdapter:
public class NoteAdapter extends ArrayAdapter<Note> {
public static class ViewHolder{
TextView noteTitle;
TextView noteBody;
ImageView noteIcon;
}
public NoteAdapter(Context context, ArrayList<Note> notes) {
super(context, 0, notes);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Note note = getItem(position);
ViewHolder viewHolder;
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_row, parent, false);
// == Here I am getting the error ==
ViewHolder.noteTitle = (TextView) convertView.findViewById(R.id.text_item_note_title);
ViewHolder.noteBody = (TextView) convertView.findViewById(R.id.text_item_note_body); …Run Code Online (Sandbox Code Playgroud)