Jump to content

Urgent Interview Question


Recommended Posts

Posted

Explain anootation based transactions in JPA or hibernate or Ibatis

same question in different way
How do you manage transaction in your persistence Layer

Please provide me answers.

Posted

[quote name='bujjulu' timestamp='1380564620' post='1304329369']
Explain anootation based transactions in JPA or hibernate or Ibatis

same question in different way
How do you manage transaction in your persistence Layer

Please provide me answers.
[/quote]
[color=#000000][font=Helvetica, Arial, sans-serif][size=3]
Hibernate annotations is the newest way to define mappings without a use of XML file. You can use annotations in addition to or as a replacement of XML mapping metadata.[/size][/font][/color][color=#000000][font=Helvetica, Arial, sans-serif][size=3]
Hibernate Annotations is the powerful way to provide the metadata for the Object and Relational Table mapping. All the metadata is clubbed into the POJO java file along with the code this helps the user to understand the table structure and POJO simultaneously during the development.[/size][/font][/color]
[b] @Entity Annotation:[/b]
[color=#000000][font=Helvetica, Arial, sans-serif][size=3]
The EJB 3 standard annotations are contained in the [b]javax.persistence[/b] package, so we import this package as the first step. Second we used the [b]@Entity[/b] annotation to the Employee class which marks this class as an entity bean, so it must have a no-argument constructor that is visible with at least protected scope.[/size][/font][/color]
[b] @Table Annotation:[/b]
[color=#000000][font=Helvetica, Arial, sans-serif][size=3]
The @Table annotation allows you to specify the details of the table that will be used to persist the entity in the database.[/size][/font][/color][color=#000000][font=Helvetica, Arial, sans-serif][size=3]
The @Table annotation provides four attributes, allowing you to override the name of the table, its catalogue, and its schema, and enforce unique constraints on columns in the table. For now we are using just table name which is EMPLOYEE.[/size][/font][/color]
[b] @Id and @GeneratedValue Annotations:[/b]
[color=#000000][font=Helvetica, Arial, sans-serif][size=3]
Each entity bean will have a primary key, which you annotate on the class with the [b]@Id[/b] annotation. The primary key can be a single field or a combination of multiple fields depending on your table structure.[/size][/font][/color][color=#000000][font=Helvetica, Arial, sans-serif][size=3]
By default, the @Id annotation will automatically determine the most appropriate primary key generation strategy to be used but you can override this by applying the [b]@GeneratedValue[/b] annotation which takes two parameters [b]strategy[/b] and [b]generator[/b] which I'm not going to discuss here, so let us use only default the default key generation strategy. Letting Hibernate determine which generator type to use makes your code portable between different databases.[/size][/font][/color]
[b] @Column Annotation:[/b]
[color=#000000][font=Helvetica, Arial, sans-serif][size=3]
The @Column annotation is used to specify the details of the column to which a field or property will be mapped. You can use column annotation with the following most commonly used attributes:[/size][/font][/color][list]
[*]
[b]name[/b] attribute permits the name of the column to be explicitly specified.
[*]
[b]length[/b] attribute permits the size of the column used to map a value particularly for a String value.
[*]
[b]nullable[/b] attribute permits the column to be marked NOT NULL when the schema is generated.
[*]
[b]unique[/b] attribute permits the column to be marked as containing only unique values.
[/list]

Posted

question adhi kadhu
[url="http://stackoverflow.com/questions/14828579/transaction-management-in-spring-3-x-and-hibernate-4"]http://stackoverflow.com/questions/14828579/transaction-management-in-spring-3-x-and-hibernate-4[/url]

×
×
  • Create New...