Hibernate是否验证临时表?

时间:2019-02-27 23:57:43

标签: mysql spring hibernate jpa jdbc

在我的Spring应用程序启动时,Hibernate正在验证数据库的MySQL模式。我的应用程序未映射的表之一被另一个应用程序删除。

这将导致错误(请参阅下面的stacktrace),因为使用同一数据库的单独应用程序正在创建没有public class ExpandableListAdapterAssets extends BaseExpandableListAdapter implements Filterable { List<View> groupViews; ItemFilter mFilter; boolean showCheckBox; ArrayList<Asset> assetsToClaim; private Context _context; private List<AssetCategory> _listDataHeader; // header titles // child data in format of header title, child title private HashMap<Integer, List<Asset>> _listDataChild; private RequestBackendHelper requestBackendHelper; public ExpandableListAdapterAssets(Context context, List<AssetCategory> listDataHeader, HashMap<Integer, List<Asset>> listChildData, boolean b) { this._context = context; this._listDataHeader = listDataHeader; this._listDataChild = listChildData; groupViews = new ArrayList<>(); showCheckBox = b; assetsToClaim = new ArrayList<>(); } @Override public Asset getChild(int groupPosition, int childPosition) { return this._listDataChild.get(this._listDataHeader.get(groupPosition).getId()) .get(childPosition); } public List<Asset> getChildList(int groupPosition) { return this._listDataChild.get(this._listDataHeader.get(groupPosition).getId()); } @Override public long getChildId(int groupPosition, int childPosition) { return childPosition; } @Override public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { final Asset assetChild = getChild(groupPosition, childPosition); if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) this._context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = infalInflater.inflate(R.layout.list_item, null); } TextView assetName = (TextView) convertView .findViewById(R.id.txt_asset_name); assetName.setText(assetChild.getName()); TextView assetValue = (TextView) convertView .findViewById(R.id.txt_asset_value); assetValue.setText(getFormattedAmount(assetChild.getValue())); ((TextView) convertView.findViewById(R.id.txt_asset_category)).setText(assetChild.getAssetCategory()); ((TextView) convertView.findViewById(R.id.txt_asset_date)).setText(assetChild.getCreationDate()); if (showCheckBox) { CheckBox itemSelect = convertView.findViewById(R.id.chkbox_item_select); itemSelect.setVisibility(View.VISIBLE); itemSelect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { assetsToClaim.add(getChild(groupPosition, childPosition)); Log.d("checkbox", "checked: "); } else { assetsToClaim.remove(getChild(groupPosition, childPosition)); } } }); } else { } return convertView; } @Override public int getChildrenCount(int groupPosition) { if (_listDataChild == null) return 0; else if (_listDataChild.size() == 0) return 0; else { int position = this._listDataHeader.get(groupPosition).getId(); int count = this._listDataChild.get(position).size(); return count; } } @Override public Object getGroup(int groupPosition) { return this._listDataHeader.get(groupPosition); } @Override public int getGroupCount() { return this._listDataHeader.size(); } @Override public long getGroupId(int groupPosition) { return groupPosition; } @Override public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, final ViewGroup parent) { if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) this._context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = infalInflater.inflate(R.layout.list_group, null); } TextView lblListHeader = (TextView) convertView .findViewById(R.id.lblListHeader); lblListHeader.setTypeface(null, Typeface.BOLD); lblListHeader.setText(_listDataHeader.get(groupPosition).getName()); groupViews.add(convertView); return convertView; } private void requestDeleteCategory(final int groupPosition) { requestBackendHelper = new RequestBackendHelper(_context); if (getChildrenCount(groupPosition) == 0) { requestBackendHelper.deleteCategory(_listDataHeader.get(groupPosition).getId(), _context.getSharedPreferences(MY_PREFS_NAME, Context.MODE_PRIVATE).getString("jwt", "") , new VolleyCallBack() { @Override public void onSuccess(String result) { try { JSONObject parentObj = new JSONObject(result); if (parentObj.getBoolean("status")) { requestBackendHelper.createErrorDialog("Category Deleted.", "success"); _listDataHeader.remove(groupPosition); _listDataChild.remove(_listDataHeader.get(groupPosition)); notifyDataSetChanged(); } else { requestBackendHelper.createErrorDialog(parentObj.getString("error"), ""); } } catch (JSONException e) { e.printStackTrace(); } } @Override public void onFailure(VolleyError error) { requestBackendHelper.createErrorDialog(error.toString(), ""); } }); } else { requestBackendHelper.createErrorDialog("The category cannot be deleted until all assets are removed.", ""); } } @Override public boolean hasStableIds() { return false; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } public List<View> getGroupViewList() { return groupViews; } private void loadEditCategoryAlertDialog(final int groupPosition) { View viewInflated = LayoutInflater.from(_context).inflate(R.layout.activity_add_category_dialog, null); final EditText nameInput = viewInflated.findViewById(R.id.categoryNameEditText); viewInflated.findViewById(R.id.categoryDescriptionEditText).setVisibility(View.GONE); final TextView errorLabel = viewInflated.findViewById(R.id.errorTextView); final AlertDialog dialog = new AlertDialog.Builder(_context) .setView(viewInflated) .setTitle("Edit Category") .setPositiveButton(android.R.string.ok, null) .setNegativeButton(android.R.string.cancel, null) .setCancelable(false) .create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { Button okButton = (dialog).getButton(AlertDialog.BUTTON_POSITIVE); okButton.setOnClickListener(new DebouncedOnClickListener() { @Override public void onDebouncedClick(View view) { final String categoryName = nameInput.getText().toString(); requestRenameCategory(categoryName, groupPosition, dialog, errorLabel); } }); } }); dialog.show(); } private void requestRenameCategory(final String categoryName, final int groupPosition, AlertDialog dialog, TextView errorLabel) { if (categoryName.isEmpty()) { errorLabel.setText(R.string.add_category_validation_error); } else { if (requestBackendHelper == null) requestBackendHelper = new RequestBackendHelper(_context); requestBackendHelper.attemptEditAssetCategory(createEditCategoryJson(categoryName), _listDataHeader.get(groupPosition).getId() , _context.getSharedPreferences(MY_PREFS_NAME, Context.MODE_PRIVATE).getString("jwt", "") , new VolleyCallBack() { @Override public void onSuccess(String result) { _listDataHeader.get(groupPosition).setName(categoryName); int size = _listDataHeader.get(groupPosition).getAssetCout(); for (Asset asset : getChildList(groupPosition)) asset.setAssetCategory(categoryName); notifyDataSetChanged(); } notifyDataSetChanged(); } @Override public void onFailure(VolleyError error) { } }); dialog.dismiss(); } } private JSONObject createEditCategoryJson(String categoryName) { JSONObject messageObj = new JSONObject(); JSONObject assetCategoryObj = new JSONObject(); try { messageObj.put("name", categoryName); assetCategoryObj.put("asset_category", messageObj); return assetCategoryObj; //contactusObj.put(message); } catch (JSONException e) { e.printStackTrace(); } return null; } /** * <p>Returns a filter that can be used to constrain data with a filtering * pattern.</p> * * <p>This method is usually implemented by {@link Adapter} * classes.</p> * * @return a filter used to constrain data */ @Override public Filter getFilter() { if (mFilter == null) { mFilter = new ItemFilter(); } return mFilter; } private class ItemFilter extends Filter { protected FilterResults performFiltering(CharSequence constraint) { FilterResults results = new FilterResults(); return results; } /** * <p>Invoked in the UI thread to publish the filtering results in the * user interface. Subclasses must implement this method to display the * results computed in {@link #performFiltering}.</p> * * @param constraint the constraint used to filter the data * @param results the results of the filtering operation * @see #filter(CharSequence, FilterListener) * @see #performFiltering(CharSequence) * @see FilterResults */ @Override protected void publishResults(CharSequence constraint, FilterResults results) { } } 关键字的“临时”表。因此,随着Hibernate开始验证架构,表explistAdapter = new ExpandableListAdapterAssets(getActivity(), assetCategories, listDataChild, false); expListView.setAdapter(explistAdapter); 存在于元数据信息中,并且在验证表的中/末尾不再存在。

如果我们将TEMPORARY设为temp_pti_id表,那么Hibernate模式验证将完全跳过它吗?或者temp_pti_id表是否计入正在分析的模式信息中?

堆栈跟踪:

TEMPORARY

0 个答案:

没有答案