是否有可能在jpa中将继承属性重新定义为瞬态?

时间:2015-08-20 10:38:00

标签: hibernate jpa orm eclipselink hibernate-mapping

public class TestFragment extends Fragment {

private AppProgressDialog progressDialog;

public static TestFragment newInstance() {

    TestFragment fragment = new TestFragment();
    return fragment;

}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    progressDialog = new AppProgressDialog(getActivity());
}

@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_login, container, false);

    Button btnTest = rootView.findViewById(R.id.btnTest);
    btnTest.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            new TestAsyncTask().execute();

        }
    });
    return view;
}

@Override
public void onSaveInstanceState(Bundle outState) {

    super.onSaveInstanceState(outState);
}

@Override
public void onResume() {
    super.onResume();
}

class TestAsyncTask extends AsyncTask<String, String, String> {

    @Override
    protected void onPreExecute() {
        progressDialog.setProgressDialogMessage("Logging you to eventizon");
        progressDialog.showProgressDialog();
    }

    @Override
    protected String doInBackground(String... params) {
        //some code
    }

    @Override
    protected void onPostExecute(String result) {
        progressDialog.dismissProgressDialog();
    }

}

是否可以将名称属性设置为仅用于B类的瞬态

1 个答案:

答案 0 :(得分:1)

不,它不起作用。始终考虑@MappedSuperclass字段/属性,即使您使用property-access并尝试使用不同的注释覆盖属性,Hibernate仍将使用基类中的属性。