quick beginner's question

(this is cross-posted, i think this forum is more appropriate than the 'javabeans' forum i originally posted in)

i was reading this from an O'Reilly book. What do the @ symbols mean? I didn't see a clear explanation of that...

import javax.persistence.* ;

@Entity

@Table(name="CABIN")

publicclass Cabin{

privateint id;

private String name;

privateint deckLevel;

@Id

@GeneratedValue

@Column(name="CABIN_ID")

publicint getId( ){return id;}

publicvoid setId(int pk){ this.id = pk;}

@Column(name="CABIN_NAME")

public String getName( ){return name;}

publicvoid setName(String str){ this.name = str;}

@Column(name="CABIN_DECK_LEVEL")

publicint getDeckLevel( ){return deckLevel;}

publicvoid setDeckLevel(int level){ this.deckLevel = level;}

}

They look to me like the names of columns for the Database that will be taking

care of the persistence for this bean. Is that right?

If so, is it safe to assume these declarations need to always be made right

the 'getter' method of that particular data element?

thanks again!

[2454 byte] By [pnandrusa] at [2007-11-27 4:42:26]
# 1

The @ symbol mark the reserved word as an annotation. The annotations was introduces in java 1.5.0. @Table, @Entity, @Id are different annotations for mapping a class to a database table, all introduced with EJB 3.0.

@Column you can write just above getter of an atribute or just above the atribute name.

You always must put the getters and setters for all persistence attributes (table fields).

Good luck.

I hope it helps you.

Hayken.

haykena at 2007-7-12 9:54:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...