What is a good inheritance strategy with Hibernate and JPA?

I have this situation:

I have an entity, Person, that contains all personal details of a person, like birth date, street address, municipality ecc ecc. And I have an entity ClubMember that describe a member of a club and contains some field like: registration date, type of member, credit, ecc ecc

So, a ClubMember is a Person, and I think is correct describe this with a inheritance: ClubMember extends Person, but, what type of strategy?

I would obtain two table in database, Person and ClubMember, with ClubMember that contain id_person like an @OneToOne relationship, but keep the inheritance between entities; is this possible (and is correct)?

JOINED is the strategy closest to my target, but I lose the ID field of table ClubMember, in fact ID become the ID of table Person


Blow, you should keep performance issues when choosing some kind of inheritance strategy. Here you can see a good insight about available inheritance strategies. Do not forget a inheritance can be re-writen as a association as follows

instead of

public class A {}

public class B extends A {}

you can use

public class B {

    private A a;


Or you can use MapedSuperClass To map all of your inherited properties whitout using any Hibernate/JPA inheritance strategy. See here

Keep in mind when using default JPA/Hibernate annotations, Hibernate always fetch all of subclasses. If you have a single hierarchy, prefer To use Single Table Inheritance strategy. Joined strategy is better designed when you have a complex hierarchy but it suffers due To performance issues when querying for any entity.


Google Search Like Widget Example

I am looking for example for Google Search like home page widget from where user can type-in keywords to search within my app. Youtube video here.

I followed the tutorial at the dev guide. However, it lists the available RemoteViews, and there is no EditView. In such case how can I provide a editable text-box. I want to build a widget similar to SearchManager UI, but available as widget at home-screen.


EditText is not available on widgets. That’s why there’s no EditText on the search widget. It just looks like EditText. When you click over the search widget it starts another activity with EditText.


How to browse localhost on Android device?

I try to browse localhost on my HTC Magic. I have connected my device with Eclipse via USB. When browsing I get “Page not available”. I remember, some days ago it worked.

But on the emulator I am able to browse localhost

Any ideas?


I use my local ip for that i.e. and it works.


How to make textarea fill the width of its parent width?

Given that we don’t know the div’s width beforehand?

My idea: Calculate the div ‘s width with JS, find a way to convert it to cols and the apply the css to the textarea onthe fly. But perhaps there ‘s no need to reinvent the wheel?

Thank you.


<textarea style="width:100%">* will work in most cases.

If it doesn’t, please provide more information!

* Note: for some reason, it will need the cols and rows attributes to validate. But setting a width or a height will override them, so put any value you want.


How to put multiple widget sizes in one apk?

What I’m trying to do is have a clock widget of different sizes (i.e. 2×2, 3×3, 4×4 etc) in one apk and a configuration activity to be able to select which size to add.

From what i’ve learned from documentation:

  1. Widget size is specified in <appwidget-provider> tag in respective xml file
  2. Also in that file I set up the configuration activity for that provider

So it seems that size is a property of AppWidgetProvider and I’ll need to somehow create another provider from the code in configuration Activity of the first one…
Or am I getting this wrong and there’s another way?

Is this possible at all? 🙂
I’ve been told that some widgets can do this 🙂

Thanks in advance!

P.S. I have read this and this. First one explains how to put multiple wigets in one apk, but it’s not clear how to select between them in runtime. Second one is about changing layouts, but not size…


Do you really have to do this at runtime? It is possible to define several widgets in one .apk.

Maybe you can have a look on transdroid source? They are including two sizes of a widget in the same package.

AndroidManifest.xml used by Transdroid

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..